linux文件比较字符串不包括在内

linux文件比较字符串不包括在内,linux,file,compare,Linux,File,Compare,如何比较LINUX中包含以下内容的2个文件: 文件1 文件2 为了得到结果 文件3 使用如何 适用于您的简单示例。如果要列出文件1中的所有行,但不列出文件2中的所有行,可以执行以下操作: diff file1 file2 | grep "^<" | sed "s/^< //" > file3 diff file1 file2 | grep”^ 1 2 3 4 5 comm -3 file1 file2 > file3 diff file1 file2 | grep

如何比较LINUX中包含以下内容的2个文件:

文件1

文件2

为了得到结果

文件3

使用如何


适用于您的简单示例。

如果要列出文件1中的所有行,但不列出文件2中的所有行,可以执行以下操作:

diff file1 file2 | grep "^<" | sed "s/^< //" > file3
diff file1 file2 | grep”^
1
2
3
4
5
comm -3 file1 file2 > file3
diff file1 file2 | grep "^<" | sed "s/^< //" > file3