Computing.Net > Forums > Unix > compare 2 rows of a file using awk

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

compare 2 rows of a file using awk

Reply to Message Icon

Name: Latha
Date: September 12, 2007 at 23:43:56 Pacific
OS: Unix
CPU/Ram: P4
Product: dell
Comment:

I need to compare two files and get the difference between the two files. F1 is the base file.I need to print out all the lines missing in F2, and the extra lines in F2 and also the mismatched lines between F1 and F2. If they are mismatching then i need to print out the exact column numbers where they are mismatching. I need to do this using unix and awk.Please help.



Sponsored Link
Ads by Google

Response Number 1
Name: Devaraj (by Fidy)
Date: September 14, 2007 at 19:32:15 Pacific
Reply:

Latha,

you can simply do a diff file1 file 2 > outfile
. read manual for diff.

Devaraj T

Regards,
Devaraj Takhellambam


0

Response Number 2
Name: Latha
Date: September 18, 2007 at 07:49:37 Pacific
Reply:

The output of diff command is diffcult to comprehend. and if both the files have the same contents but if the order is different, still it says they are different.


0

Response Number 3
Name: Devaraj (by Fidy)
Date: September 20, 2007 at 19:13:39 Pacific
Reply:

Latha,

You should first sort both the files - if u have a key to sort..it will e best..or else just do a simple sort and then do a diff

eg sort file1 > sfile1
sort file2 > sfile2
diff sfile1 sfile > difile

If you can give me a sample of both the file, I may be able to help you more..

Cheers,
Devaraj Takhellambam

Regards,
Devaraj Takhellambam


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


deleting a link in UNIX Help Needed



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: compare 2 rows of a file using awk

Comparing time/date of a file... www.computing.net/answers/unix/comparing-timedate-of-a-file/3711.html

update the contents of a file in Un www.computing.net/answers/unix/update-the-contents-of-a-file-in-un/5963.html

Delete first line of a file www.computing.net/answers/unix/delete-first-line-of-a-file/7594.html