More fun with UNIX find and grep – how to silence grep error messages

Use find to search an entire directory tree and return filenames that include a string:

find . -name "*" -exec grep -ils Jan28 # {} \;
./junkDir/myfile
# cat ./junkDir/myfile
Jan28

the -s switch on the embedded grep silences error messages including:

grep: ./junkDir: Is a directory

Leave a Comment

Scroll to Top