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