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 -->
  #7 (permalink)  
Old 02-09-2007
bucci bucci is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 81
its work

thank you

Quote:
Originally Posted by radoulov
I don't understand what exactly you're trying to accomplish
with your script, but with ORS="," you'll get an extra "," and no new line at the end:


Code:
$ nawk '$12=="00008001"{!cs_cd[$11]++}END{for(cd in cs_cd)print cd}' ORS="," infile
133,123,

BTW if you want to preserve the order (123, 133 ...):


Code:
nawk '$12=="00008001"&&!x[$11]++{print $11}' ORS="," infile


Given your original code (and not the sample output)
it _seems_ you want something like this:


Code:
nawk '$12=="00008001"{cs_cd[$11]++}END{for(cd in cs_cd)print cd,cs_cd[cd] }' ORS="," infile