Skip to main content

Exclude directory from grep search

· One min read
Tien
  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?