我有 4 个包含服务器名称的文本文件,如下所示:(每个文件大约有 400 行,其中包含各种服务器名称)
Server1
Server299
Server140
Server15
我想比较这些文件,我想找到所有 4 个文件共有的服务器名称。
我不知道从哪里开始 - 我可以访问 Excel 和 Linux bash。有什么巧妙的想法吗?
我在 Excel 中使用 vlookup 来比较 2 列,但不认为这可以用于 4 列?
最佳答案
一种方法是说:
cat file1 file2 file3 file4 | sort | uniq -c | awk '$1==4 {print $2}'
另一种方式:
comm -12 <(comm -12 <(comm -12 <(sort file1) <(sort file2)) <(sort file3)) <(sort file4)
关于excel - 如何在多个文件中查找常用单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18869928/