grep but exclude directory 1

grep but exclude directory

grep -rli --exclude-dir={dir1,dir2,dir3} keyword /path/to/search

Here is what the above code is Doing:
1. The -r option tells grep to search recursively through the directory.
2. The -l option tells grep to only print the name of the file that contains the keyword.
3. The -i option tells grep to ignore case.
4. The –exclude-dir option tells grep to ignore the directories listed.
5. The keyword is the word you’re searching for.
6. The /path/to/search is the directory you want to search.

Similar Posts