Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find different adjacent columns.

Status
Not open for further replies.

TheDash

MIS
Mar 25, 2004
171
US
i have a large text file which is the output of a large sql join selecting all cols of two tables a and b. It is in the form acol1, bcol1, acol2, bcol2 etc ... acol100, bcol100 .. Almost all cols are same i.e acol1=bcol1 etc.. except one or two that are different and it is difficult and error prone to identify them in excel or txt file. I am looking for a script that will identify the cols that are different in each line (result row) and print it. ie. if acol40 and bcol40 and acol56 and bcol56 are different, print them. these are text cols. therefore they are separated by commas and enclosed in ". Thanks in advance.
 

Maybe something like this:
Code:
awk -F, '{for (i=1;i<=NF;i=i+2) if ( $i != $(i+1) ) print "Line " NR " has diff= "$i"<>"$(i+1);}' My_Data
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top