diff to show differed lines only (hiding common lines)
diff to show differed lines only (hiding common lines)
(OP)
hi,
I am comparing 2 TXT files, each one has millions of rows, to know the differed rows.
How can I hide common rows in the resultant files? please help.
My command: diff -u -w <sort file1) <(sort file2) > file3.res
My file1:
a1 Bala
a2 vup
a3 jivup
My file2:
a1 Bala
a2 Vup
a3 jivup
b1 abc
file3.res from present command:
a1 Bala
a3 jivup
-a2 vup
+a2 Vup
+b1 abc
O/p file that I want to see:(hide all common rows, show only differed rows)
-a2 vup
+a2 Vup
+b1 abc
Cheers,
BauV
I am comparing 2 TXT files, each one has millions of rows, to know the differed rows.
How can I hide common rows in the resultant files? please help.
My command: diff -u -w <sort file1) <(sort file2) > file3.res
My file1:
a1 Bala
a2 vup
a3 jivup
My file2:
a1 Bala
a2 Vup
a3 jivup
b1 abc
file3.res from present command:
a1 Bala
a3 jivup
-a2 vup
+a2 Vup
+b1 abc
O/p file that I want to see:(hide all common rows, show only differed rows)
-a2 vup
+a2 Vup
+b1 abc
Cheers,
BauV
RE: diff to show differed lines only (hiding common lines)
I am afraid this works only in GNU diff, but give it a try :
CODE
Feherke.
feherke.github.io
RE: diff to show differed lines only (hiding common lines)
Unfortunately it's not working, my Linux 5.10 says "...illegal option -- unchanged-line-format=".
Even "diff file1.txt file2.txt |grep -E ’<|>’ > outputfile.txt" also says "....illegal option -- E..".
Any further suggestion is appreciable.
Cheers,
BauV
RE: diff to show differed lines only (hiding common lines)
This one worked for me excluding the lines that start with 1 space.
diff file1.txt file2.txt |grep -v '^ ' > outputfile.txt
Cheers,
BauV