MagoNick MagoNick - 3 months ago 11
Linux Question

Grep on source code excluding build folders

I use grep to look for a variable usage or a function call in the following way

grep -Rni <function_name>


However, the search also includes my build and build_debug folders.
Considering the case in which my code is structured as following

root/
|
->build
|
->build_debug
|
->pkg_1
|
->src
|
->include
->pkg_2
|
->src
|
->include


How can I modify the query so that it does not look into build and build_debug?
Thanks!

Answer
grep --exclude-dir build --exclude-dir build_debug -Rni
Comments