我可以使用diff或其他工具的哪些标志来比较两个文件中文本块的差异。 EX:
文件1
record {
data1
data2
}
file2的
record {
data1
data2
}
record {
data3
data4
}
,输出就像
record {
data3
data4
}
答案 0 :(得分:1)
您可以使用diff
命令作为
diff -a --suppress-common-lines file2 file1
(或)使用grep
作为
grep -Fxvf file1 file2
使用以下标志
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched.
-x, --line-regexp
Select only those matches that exactly match the whole line.
-v, --invert-match
Invert the sense of matching, to select non-matching lines.
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing.
使用awk
awk 'NR == FNR {unique[$0]++; next} !($0 in unique)' file1 file2