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.
假设有一个文件details,其中有一个单词列表,例如adobe,cards等等……说那个文件中有 1000 个单词。在同一个目录中有多个文件,比如 2000 个文件。
details
adobe
cards
现在我需要的是 shell 脚本来捕获文件中的哪些单词details在哪个文件中使用,然后将其写入另一个文件,例如:
adobe-file1 cards-0(i.e not used any where) state-file1,file2
为文件中的每个单词detail创建一个扩展名的.r文件,其中包含找到该单词的任何文件名:
detail
.r
grep -rowf detail --exclude=detail | sort -t: -k2 | awk -F: '{print $1>($2".r")}'