mattalxndr mattalxndr - 2 years ago 119
Linux Question

Grep: Excluding a specific folder using

Say our folder structure looks like this:

/app
/app/data
...
/app/secondary
/app/secondary/data


I want to recursively search
/app/data
but I do not want to search
/app/secondary/data
.

From within the app folder, what would my grep command look like?

Answer Source

This will do the trick

grep -r --exclude-dir='secondary/data' PATTERN data
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download