How do you exclude a specific file from ack (ack-grep)?

ack
machineghost picture machineghost · Jul 24, 2012 · Viewed 18.3k times · Source

With the normal grep command there is an --exclude option (covered in detail here: Use grep --exclude/--include syntax to not grep through certain files) that lets you ignore specific files when you are grepping.

Ack's --type option takes care of 95% of the cases where you'd want to exclude files, but it doesn't (as far as I can tell) handle the case of excluding a specific file. I've got a compiled JS file that has the contents of every other JS file in it (on a single line), so every time I grep for anything I get back the entire contents of that giant compiled file.

I'd hate to have to give up on ack and go back to grep over this, but it is really annoying. Please, someone tell me there's a way to exclude specific files from ack searches.

Answer

jbouwman picture jbouwman · Jun 14, 2013

To ignore a single file using ack 2.0, provide a filter spec to the --ignore-file flag:

--ignore-file=is:cljout.js