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... Commented 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. Commented Jul 11, 2019 at 15:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.