My source file is comma delimited and the sixth delimeter has trailing spaces. I am using the following awk command and getting 0 line count : awk -F\, '$6 == "EXTINCT" { print }' IDCSRC.CSV|wc -l
When using the other version with trailing space I am getting correct line count back :
awk -F\, '$6 == "EXTINCT " { print }' IDCSRC.CSV|wc -l
1747512
How can i trim the 6th delimeter in the first version of the awk command to get the right number of lines ?
Thanks
Wasim
awk's gsub function can remove all the spaces in field 6. Unfortunately on Solaris 9 I had to use nawk and the short hand awk notation would not work with the incusion of gsub: awk -F"," ' { gsub(" *","",$6) if($6 == "EXTINCT") print }' IDCSRC.CSV|wc -l
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |