ack: Exclude specific directories from search via regex
With ack2, it seems you can't use holygeek's solution.
Here's how I'd do it using -v
and -x
:
ack -v -g 'test' | ack -x pattern
More generally, 'test'
can be a regex for dirs to exclude
Use the undocumented option "--invert-file-match" (ack version on my system: 1.96):
$ ack pattern -G 'test|tests' --invert-file-match
Well, it is sort of documented:
$ ack --help|grep invert
-v, --invert-match Invert match: select non-matching lines
--invert-file-match Print/search handle files that do not match -g/-G.
It is not documented in its perldoc.