用ack搜索多个模式(单词)? [英] Searching multiple patterns (words) with ack?

查看:150
本文介绍了用ack搜索多个模式(单词)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在目录中搜索多个模式,其中包含递归目录 files



我知道 grep

  grep -e'(pattern1)|(pattern2)'

  grep -r -E'string1 | string2 | string3'/ var / www / http 

这个命令是什么使用 ack ag

解决方案 $ p
$ b

  ack -R'string1 | string2'

由于 -R 是默认值,所以您可以忽略它:

  ack'string1 | string2'






man ack


-r -R ,--recurse

递归到子目录。这是默认值,只是在这里
与grep兼容。 b






p>如果你想从文件中获取模式,比如/path/to/patterns.file,你可以使用:

  ack$(cat /path/to/patterns.file)

或等价: p>

  ack$(< /path/to/patterns.file)

我无法找到与 grep -f 完全等价的内容。


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

I know command for grep which is as follows

grep -e '(pattern1)|(pattern2)'

or

grep -r -E  'string1|string2|string3' /var/www/http

What is the command for that using ack or ag?

解决方案

This should be enough:

ack -R 'string1|string2'

As -R is the default, you can omit it:

ack 'string1|string2'


From man ack:

-r, -R, --recurse

Recurse into sub-directories. This is the default and just here for compatibility with grep. You can also use it for turning --no-recurse off.


If you want to get the pattern from a file, say /path/to/patterns.file, you can use:

ack "$(cat /path/to/patterns.file)"

or equivallently:

ack "$(< /path/to/patterns.file)"

I cannot find an exact equivalent to grep -f.

这篇关于用ack搜索多个模式(单词)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆