Code:
#!/bin/bash
SEARCHTERMS="/path/to/searchterms.txt";
WEBPAGES="/path/to/webpagelist.txt";
RESULTSFILE="/path/to/results.txt";
while read searchTerm; do
blnFound=0;
while read webPage; do
tempFile=`mktemp`;
if ! wget -q "${webPage}" -O "${tempFile}"; then
echo "ERROR: Failed to download ${webPage} to temp file ${tempFile}...";
exit 1;
fi
if grep "${searchTerm}" "${tempFile}" > /dev/null; then
blnFound=1;
echo "${searchTerm} yes" >> "${RESULTSFILE}";
break;
fi
done < "${WEBPAGES}"
if [ "${blnFound}" == "0" ]; then
echo "${searchTerm} no" >> "${RESULTSFILE}";
fi
done < "${SEARCHTERMS}"
Alternatively, if you really want to modify the original file with the search terms, change the echo's above to output only yes or no, and then add this to the end of the above:
Code:
tempFile=`mktemp`;
paste "${SEARCHTERMS}" "${RESULTSFILE}" > "${tempFile}";
mv "${tempFile}" "${SEARCHTERMS}";
Note: none of the above is tested...
Bookmarks