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 -->
  #2 (permalink)  
Old 06-18-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652

Code:
awk -F, '
NR==1 { expect=$NF; fields=NF; last=0 }
NF != fields { last=NR;
  if (NR != 2) print NR ": wrong number of fields: " $0;
  if ($NF != expect) print NR ": last field value not the same as on first line"
  if ($NF != NR-2) print NR ": last field not equal to line count minus two"
  if ($NF != expect) print NR ": line count from first line not identical"
}
last > 0 && NR > last { print NR ": wrong number of fields: " $0 }' QDB_2008.txt

Slightly unwieldy, but should hopefully at least get you started.