0

假设有一个文件details,其中有一个单词列表,例如adobecards等等……说那个文件中有 1000 个单词。在同一个目录中有多个文件,比如 2000 个文件。

现在我需要的是 shell 脚本来捕获文件中的哪些单词details在哪个文件中使用,然后将其写入另一个文件,例如:

adobe-file1
cards-0(i.e not used any where) 
state-file1,file2
4

1 回答 1

4

为文件中的每个单词detail创建一个扩展名的.r文件,其中包含找到该单词的任何文件名:

grep -rowf detail --exclude=detail | sort -t: -k2 | awk -F: '{print $1>($2".r")}'
于 2013-09-25T12:09:05.960 回答