Grep: exclude a directory

I often forget this so I'm jotting it down, despite the parameter being self-explanatory and well-named.

grep -r 'hello' . This recursively searches the current directory for files matching 'hello'.

But you may have an incredibly large folder with images in it. And grep will take ages to search all the files.

So grep -r 'hello' --exclude-dir=images . will exclude the folder images.

unix

Edit on github
comments powered by Disqus
Click me