This Bash script searches for specific keywords in a list of websites and outputs the results to a file. It colorizes the output based on the status of each domain:
- Domains that cannot be resolved are colorized red.
- Domains with keywords found are colorized green.
- Domains with keywords not found are colorized white.
- Bash
curl
command-line tool
- Clone the repository or download the script.
- Ensure the script is executable:
chmod +x search_keywords.sh
- Add your list of keywords to a file named
keywords.txt
, with one keyword per line. - Add your list of URLs to a file named
domains.txt
, with one URL or domain per line. - Run the script:
./search_keywords.sh
- The script will process each URL and output the results to a file named
output.txt
. - If the file does not exist, you will be prompted to provide the path to another file.
If the script is terminated (e.g., with Ctrl+C
) and then restarted, it will continue processing from the last domain in the output.txt
file. This ensures that already processed URLs or domains are not re-processed.
Processing domain 1 of 5: example.com (keywords found)
Processing domain 2 of 5: nonexistentdomain.com (could not be resolved)
Processing domain 3 of 5: anotherexample.com (keywords not found)
In the above example:
example.com
contained one or more of the specified keywords and is displayed in green.nonexistentdomain.com
could not be resolved and is displayed in red.anotherexample.com
did not contain any keywords and is displayed in white.
The script reads keywords from the keywords.txt
file and domains from the domains.txt
file. It then fetches the content of each URL and searches for the keywords. The results are printed to the terminal with appropriate colors and saved to the output.txt
file. The script also handles termination signals to ensure that results are saved before exiting.
If the script is terminated (e.g., via SIGINT
or SIGTERM
), it will call the cleanup
function to save the results to the output.txt
file before exiting. When restarted, the script will continue processing from the last domain in the output.txt
file.
- Ensure that the
keywords
anddomains
txt files are in the same directory as the script. - The script uses
tput
for colorizing the output. Make sure your terminal supportstput
.
Star ★ this repo, and we're square 🤓
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported.
See LICENSE for details.