比较2个文件的每行的差异,比较习惯用diff。其实还有个命令可以比较两个不同文本之间的差异comm,comm的使用说明是这样说的:
[root@xxx-xxx-xxx ~]
# comm --help
Usage:
comm
[OPTION]... FILE1 FILE2
Compare sorted files FILE1 and FILE2 line by line.
With no options, produce three-column output. Column one contains
lines unique to FILE1, column two contains lines unique to FILE2,
and column three contains lines common to both files.
-1 suppress column 1 (lines unique to FILE1)
-2 suppress column 2 (lines unique to FILE2)
-3 suppress column 3 (lines that appear
in
both files)
--check-order check that the input is correctly sorted, even
if
all input lines are pairable
--nocheck-order
do
not check that the input is correctly sorted
--output-delimiter=STR separate columns with STR
--help display this help and
exit
--version output version information and
exit
Note, comparisons honor the rules specified by `LC_COLLATE'.
Examples:
comm
-12 file1 file2 Print only lines present
in
both file1 and file2.
comm
-3 file1 file2 Print lines
in
file1 not
in
file2, and vice versa.
|
比较的文件必须是排序sort和去重uniq后的文件,切记!
参数-12,输出两个文件相同的部分
参数-1,分两块输出,第一块是相同部分,第二块是第二个文件特有的部分
参数-2,分两块输出,第一块是第一个文件特有的部分,第二块是相同部分
参数-3,分两块输出,第一块是第一个文件特有的部分,第二块是第二个文件特有的部分
不加参数,分三块输出,第一个文件特有部分、相同部分、第二个文件特有部分