我想知道如何在一个列上加入两个文件并删除重复项。首先举一些例子。
文件1:
SERVER1; Deployed; Infrastructure
SERVER2; Deployed; Infrastructure
SERVER3; Deployed; Infrastructure
SERVER4; Deployed; Infrastructure
SERVER5; Deployed; Infrastructure
文件2:
SERVER1;
SERVER2;
SERVER5;
期待:
SERVER3; Deployed; Infrastructure
SERVER4; Deployed; Infrastructure
尝试过类似的命令:sort File1 File2 | uniq > File3,但是它只返回合并的输出,因为它确实将每一列视为唯一,输出类似于:
SERVER1;
SERVER1; Deployed; Infrastructure
SERVER2;
SERVER2; Deployed; Infrastructure
SERVER3; Deployed; Infrastructure
SERVER4; Deployed; Infrastructure
SERVER5;
SERVER5; Deployed; Infrastructure
然后尝试使用命令从上面获得的内容中删除重复项awk -F";" '!_[$1]++' File3,但似乎只删除了一个重复行,而另一行是:
SERVER1;
SERVER2;
SERVER3; Deployed; Infrastructure
SERVER4; Deployed; Infrastructure
SERVER5;
我想检查重复项并删除重复项和服务器本身,您有什么建议吗?
慕无忌1623718
胡说叔叔
慕田峪9158850