This question already has an answer here:
I have a directory with some files. I want to know if a word exists in each file and then to print the filename along with a message "word exists" if the word exists and with the message"word doesnot exist" if the word does not exist in the file. $1 is my directory that I give it as a parameter
I have written this code but the terminal doesnot run the commands and does not any er*ors. How can I fix it?
#!/bin/bash for a in $( find "$1" -type f ) do if grep -q 'it21754' "$a" then grep -l "$a";echo "word exists" else grep -l "$a";echo "word does not exist" fi done