Searching multiple patterns (words) with ack?

前端 未结 4 1282
臣服心动
臣服心动 2021-01-02 03:39

I want to search multiple patterns in a directory containing recursive directories and files.

I know command for

4条回答
  •  既然无缘
    2021-01-02 04:09

    For ag, as of verion 0.19.2 the default is to search in directories and files recursively.

    To search for multiple patterns, you can use similiar syntax as ack

    ag 'pattern1|pattern2'
    

    will search for both pattern1 and pattern2.

    In case you don't want to search recursively, you can set the search depth to 1 by the switch --depth NUM

    Therefore,

    ag 'pattern1|pattern2' --depth 1
    

    will only search in the current directory for both patterns.

提交回复
热议问题