I have 2 files for comparison. I want Transfer the different records from both the files in two separate file.
A|B|C|D 1|2|3|5 E|F|G|H
A|B|C|D 1|2|3|4 E|F|I|H
Output Like... File3.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You can do this by using
comm file1 file2 -23 > file3 comm file1 file2 -13 > file4
-23 means "only lines unique to FILE1"
-13 means "only lines unique to FILE2"
diff File1 File2 | grep "^<" | sed 's/^< //g' > File3 diff File1 File2 | grep "^>" | sed 's/^> //g' > File4
cat File3 1|2|3|5 E|F|G|H cat File4 1|2|3|4 E|F|I|H