Linux: How to search a string with in a directory and the sub directories.

You can use -R in Grep for recursive. We can also use -e which is not mandatory. -e is meant for regex for search. Following are the list of commands to search a string with in a directory and all its subdirectories.

grep -r 'searchstring' directory/
 
find dir/ -TYPE f -EXEC grep -H 'string' {} +
 
grep -r -e 'searchstring*' directory/
 
grep -nr 'searchstring*' directory/
Category: