Recursive search in files on Linux
Posted #CaffeeLog#Linux

Sometimes I’m searching for a specific function in the many files and directories of a project.
Of course, I could use heavy, often crashing and expensive IDEs to do this but there is one simple and fast method using the “boring” command line and the “ugly” tool grep
:
(Maybe I should note, that the “” in this case may mean some irony)
grep -E -lir --include=*.{c,cpp,h,hpp} "void test()"
The options:
-E
enables the search with extended regular expressions, on Linux you can also useegrep
instead (mostly)-l
list not the matches, but list the filenames instead-i
ignore case-r
search recursive--include=*.{fileendings}
you can specify the wanted file endings (or other part of the name, using wildcards)
So, no need for a heavy IDE ;)