我想找到两个文件之间的差异,然后仅将差异放在第三个文件中。我看到了使用awk,diff和comm的不同方法。还有吗?
我需要知道对于以下每种情况,找到所有差异并将其列出在文件中的最快方法是-
Case 1 - file2 = file1 + extra text appended.
Case 2 - file2 and file1 are different.
你可以试试..
comm -13 <(sort file1) <(sort file2) > file3
要么
grep -Fxvf file1 file2 > file3
要么
diff file1 file2 | grep "<" | sed 's/^<//g' > file3
要么
join -v 2 <(sort file1) <(sort file2) > file3
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句