0

I have 2 files for comparison. I want Transfer the different records from both the files in two separate file.

File1

A|B|C|D

1|2|3|5

E|F|G|H

File2

A|B|C|D

1|2|3|4

E|F|I|H

Output Like... File3.

1|2|3|5

E|F|G|H

File4.

1|2|3|4

E|F|I|H

2 Answers 2

2

You can do this by using comm.

comm file1 file2 -23 > file3
comm file1 file2 -13 > file4

-23 means "only lines unique to FILE1"

-13 means "only lines unique to FILE2"

1
  • you can add "--nocheck-order" to ignore warning...
    – Siva
    Jul 11, 2019 at 12:53
0

Try this,

diff File1 File2 | grep "^<" | sed 's/^< //g' > File3
diff File1 File2 | grep "^>" | sed 's/^> //g' > File4

output:

cat File3
1|2|3|5
E|F|G|H

cat File4
1|2|3|4
E|F|I|H
1
  • Thank you. its working fine.
    – user331814
    Jul 11, 2019 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.