我正在尝试对一组文件使用 pcregrep 多行匹配。这些文件本身会从当前目录中进行一些搜索,如下所示:
l | grep -P "\d\.mt.+" | cut -d":" -f 2 | cut -d" " -f 2 | xargs
所以,我想对这组文件执行 pcregrep,这是一个多行匹配,如下所示:
pcregrep -Mi "index(.+\n)+" list of files
我不知道是否可以提供这样的文件名列表。
有人可以帮忙吗?
问候, 马努
最佳答案
试试这个:
l | grep -P "\d\.mt.+" | cut -d":" -f 2 | cut -d" " -f 2 | xargs pcregrep -Mi "index(.+\n)+"
您的命令在末尾提供了xargs
,但没有命令使用它。
现在,xargs 很有用,命令就像
pcregrep <*list of all found files*>
这就是 xargs 背后的想法。
关于regex - 对多个文件使用 pcregrep,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27386426/