The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 08-06-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380

Code:
paste file1 file2 | awk -F '\t' '
{
  fnum1 = split($1,a,",")
  fnum2 = split($2,b,",")

  linediff=0
  f=0
  while ( ++f <= fnum1 ) {
    if ( a[f] != b[f] ) { ++diff[f]; ++linediff }
  }
}
END {
  while ( ++n <= fnum1 ) {
    print n,diff[n]+0
  }
}
'


Last edited by cfajohnson; 08-06-2008 at 06:35 PM..