我有一个命令对包含"TypeId: 0"的完整路径文件进行grep,下面是命令
grep -rnw /home/username/app/data/store/0/part/.mv -e "TypeId: 0" | awk -F ":" '{print $1}'
,结果如下:/home/username/app/data/store/0/part/.mv/521/1673332792072/segmentconfig.yaml /home/username/app/data/store/0/part/.mv/521/1673333077920/segmentconfig.yaml /home/username/app/data/store/0/part/.mv/521/1673333077920/segmentconfig.yaml.old /home/username/app/data/store/0/part/.mv/515/1672993850766/segmentconfig.yaml /home/username/app/data/store/0/part/.mv/515/1672993850766/segmentconfig.yaml.old /home/username/app/data/store/0/part/.mv/703/1672987004847/segmentconfig.yaml /home/username/app/data/store/0/part/.mv/703/1672987004847/segmentconfig.yaml.old
现在我困惑如何从该列表中的每个文件grep "numofvertice"
。有人有办法解决这个问题吗?
你可以试试:
grep -rnw /home/username/app/data/store/0/part/.mv -e "TypeId: 0" | awk -F ":" '{print $1}'|xargs -I{} grep "numofvertice" {}
像这样(GNUgrep
):
<STDIN> | grep -oP 'bS+.yaml' | xargs cat
或带ack:
cd /home/username/app/data/store/0/part/.mv
ack -wl -e "TypeId: 0" | xargs cat
Fromack --help
:
-l,——files-with-matches
只打印包含匹配项的文件名