我需要比较lunix中两个文件之间的差异,我需要交集,例如我在第一个文件test.txt中的这行
aaaa 布布 CCCC dddd
在第二个文件 test2.txt 中这行
哎呀 噗噗 啊啊啊 咕咕 dddd
我需要这样的结果
aaaa dddd
我使用这个命令
comm -23 <(sort -i /var/test.txt) <(sort -i /var/test2.txt) > g.txt
这就是结果
bbbb cccc
我需要 test 和 test1 之间的交集任何帮助
grep 获取内存
最佳答案
人通讯
:
EXAMPLES
comm -12 file1 file2
Print only lines present in both file1 and file2.
所以:
$ comm -12 <(sort -i test.txt) <(sort -i test2.txt)
aaaa
dddd
关于linux - linux下两个文件的交集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47034924/