linux grep exclude code example
Example 1: grep but exclude directory
grep -rli --exclude-dir=/path/to/exclude "keyword"
Example 2: grep exclude directory
grep -rli --exclude-dir={dir1,dir2,dir3} keyword /path/to/search
Example 3: grep exclude
Just filter your output with:
grep -v "excluded_pattern"
Example to get all not txt files in current directory.
ls | grep -v .txt
Example 4: grep excep
# grep anything inside any file
grep -R "yourWord" ./path