I want to exclude the file ./test/main.cpp from my search.Here's what I'm seeing:$ grep -r pattern --exclude=./test/main.cpp./test/main.cpp:pattern./lib/main.cpp:pattern./src/main.cpp:patternI know it is possible to get the output that I want by using multiple commands in a pipes-and-filters arrangement, but is there some quoting/escaping that will make grep understand what I want natively?
Run `grep` excluding a file in a specific path
command line;grep
grep can't do this for file in one certain directory if you have more files with the same name in different directories, use find instead:find . -type f \! -path './test/main.cpp' -exec grep pattern {} \+