9
2
Given two files, I want to write a shell script that reads each line from file1 and checks if it is there in file2. If a line is not found it should output two files are different and exit. The files can contain words numbers or anything. For example :
file1 :
Hi!
1234
5678
1111
hello
file2:
1111
5678
1234
Hi!
hello
In this case two files should be equal. if file2 has "hello!!!" instead of "hello" then the files are different. I'm using bash script. How can I do this. It is not important that I need to do it in a nested loop but that's what I thought is the only way. Thanks for your help.
What if the file is a csv file. would sorting still work ? – 0x0 – 2011-01-18T17:36:55.037
sort
doesn't care about the exact contents unless you tell it to. – Ignacio Vazquez-Abrams – 2011-01-18T17:37:47.827Is it possible to find which lines differ ? – 0x0 – 2011-01-19T02:07:04.283
Remove
--brief
and add format options, e.g.-u
. – Ignacio Vazquez-Abrams – 2011-01-19T02:07:43.800