The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
comparing files - adding/subtracting/formating columns oabdalla Shell Programming and Scripting 7 06-13-2008 12:20 AM
Comparing similar columns in two different files ragavhere Shell Programming and Scripting 13 04-16-2008 05:53 AM
Comparing the common columns of a table in two files ragavhere SUN Solaris 1 04-11-2008 05:41 AM
Comparing Columns of two FIles ggopal Shell Programming and Scripting 4 02-21-2007 05:06 PM
comparing shadow files with real files terrym UNIX for Advanced & Expert Users 4 02-08-2007 11:38 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-16-2007
Registered User
 

Join Date: Feb 2007
Posts: 4
Comparing Columns of two FIles

Dear all,

I have two files in UNIX File1 and File2 as below:

File1:
1,1234,.,67.897,,0
1,4134,.,87.97,,4
0,1564,.,97.8,,1

File2:
2,8798,.,67.897,,0
2,8879,.,77.97,,4
0,1564,.,97.8,,1

I want to do the following:
(1) Make sure that both the files have equal number of columns and if not error out
(2) If there are equal number of columns then compare each corresponding field from both the files line by line and if there is any difference then print the two different values with line number and column number.

I know that 'diff -w' is useful here because it compares ignoring leading, trailing or in-between spaces which is useful because all my columns are numeric.

Can I use say 'awk' and its NF and NR variables along with diff? Or is there any other way? Please advise. I thank you for your help.

GG
Forum Sponsor
  #2  
Old 02-17-2007
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
Please do not cross-post.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0