gpt4 book ai didi

linux - linux下两个文件的交集

转载 作者:太空宇宙 更新时间:2023-11-04 04:55:33 26 4
gpt4 key购买 nike

我需要比较lunix中两个文件之间的差异,我需要交集,例如我在第一个文件test.txt中的这行

aaaa布布CCCCdddd

在第二个文件 test2.txt 中这行

哎呀噗噗啊啊啊咕咕dddd

我需要这样的结果

aaaadddd

我使用这个命令

comm -23 <(sort -i  /var/test.txt) <(sort -i  /var/test2.txt) > g.txt

这就是结果

bbbbcccc

我需要 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com