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 03-15-2008
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 393
Check this way:
Code:
> cat file
A|xyz|1000|mm
B|9000|xyz|ss
C|BDE|2000|kk
D|xyz|1000|nn
Code:
>  awk '{printf("%s","line="NR);a=gsub(/\|/,"",$1);if (a==3){print "(Not Found)";next}print "(column="a+1")"}' FS='xyz' file
line=1(column=2)
line=2(column=3)
line=3(Not Found)
line=4(column=2)