Exclude directory from grep search

  1. If we want to exclude abc/ and xyz/ directory (in root directory) form grep’s results we can do this:
    grep -rn –exclude-dir={abc,xyz} “text to find”
  2. If we want to exclude abc/def/some_thing_special/ghi…:
    grep -rn –exclude-dir={some_thing_special} “text to find”
  3. Do you know how to exclude the whole directory path?
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s