How to find file that contains a specific word in Linux and Unix.

The find and grep command is very handy when searching for files that contains a specific word. Both the find and grep commands are universal in Linux and Unix and the syntax is very similar.

Below is an example.

find /home/andrew -type f -exec grep -H ‘networks’ {} \;

This will display all files in the directory /home/andrew that contains the word networks abd output it to screen.

Here is another example using the grep command alone.

grep -r “networks” /home/andrew