ack: Exclude specific directories from search via regex

后端 未结 4 877
小蘑菇
小蘑菇 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:23

    In the interest of folks using a pre-1.96 version of ack (like me), you can use regex look around to do this. Here's an example:

    ack --java 'text-pattern' -G '^((?!(test|target)).)*$'
    

    This will search the text-pattern in all Java files recursively (from .) that DO NOT have the words test or target in their path.

提交回复
热议问题