Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我这样做ag -l foo。这让我得到一个文件列表。
ag -l foo
我如何才能再次使用 ag 在这些文件中进行搜索?
假设您在 bash shell 中,您可以这样做:
ag whatever $(ag -l foo)
所以要找到所有匹配 cat 和 dog 的文件:
ag cat $(ag -l dog)
你也可以使用xargs:
xargs
ag -l dog | xargs ag cat
如果您使用ack了另一个类似 grep 的工具,则可以使用该-x选项从标准输入读取输入文件列表:
ack
-x
ack -l dog | ack -x cat