我正在努力学习shell编程,为此,我在windows 10中使用ubuntu应用程序,我读到了comm命令,正如我所理解的,它应该如下所示。
file1.txt file2.txt
abc abc
cde efg
a b
b c
the result should be
a
cde
abc
b
c
efg
but what I am getting is
abc
a
cde
b
efg
abc
c这就是我如何使用命令
comm file1.txt file2.txt我怀疑这是因为我正在使用它的窗口应用程序,但其他命令,如grep uniq ps pwd .一切正常,如有任何帮助将不胜感激。
发布于 2019-11-06 07:38:44
这里的问题不是窗户。你用错了comm。man comm态
通讯-逐行比较两个排序的文件
因此,您必须先对两个文件进行排序。
使用
sort file1.txt > file1sorted
sort file2.txt > file2sorted
comm file1sorted file2sorted或者如果您使用的是bash (而不是普通的sh或其他shell)
comm <(sort file1.txt) <(sort file2.txt)https://stackoverflow.com/questions/58725008
复制相似问题