ack: Exclude specific directories from search via regex

后端 未结 4 830
小蘑菇
小蘑菇 2021-02-01 16:31

How do I ignore specific directories via RegEx with ack?

I can use the --ignore-dir option, but this does not let me specify a RegEx. I want to be able to i

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 17:13

    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.

提交回复
热议问题