How to grep a string or a text in a directory and all its subdirectories'files in LINUX ??
If your grep supports -R, do:
-R
grep -R 'string' dir/
If not, then use find:
find
find dir/ -type f -exec grep -H 'string' {} +
How do I recursively grep all directories and subdirectories? find . | xargs grep "texthere" *
I am working on writing some scripts to grep certain directories, but these directories contain all sorts of file types. I want to grep just .h and .cpp for now, but maybe a few others in the future. So far …
I want to traverse all subdirectories, except the "node_modules" directory.