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.
假设我有一个扩展名为 .txt 的文件列表。
而且我想知道与正则表达式模式匹配的文件的名称是什么,我将如何在 linux 中做到这一点。
现在我正在做:
cat *.txt | grep -f list.txt
其中 list.txt 包含正则表达式模式列表。
此命令仅显示模式已匹配,但我看不到匹配它的文件的名称...
将这两个条件加入如下:
grep -f list.txt *.txt
据我了解,您只需要名称,因此需要-l参数。
-l
grep -l -f list.txt *.txt