I have this file
a deiauk Biking US 200 G
b kespaul 202 A
c deiauk NY 222 5 Z
And I want to match the exact string 200 using awk
.
So my result should be
a deiauk Biking US 200 G
Here's my code
awk -F ' ' '{if($(NF-1) ~ /200/){a[$1]++}}END{for (var in a){print a[var] " " var " " $(NF-1)}}' file.txt
But after that I got all lines.
awk
code to print a single line? Did you even bother to understand what this is supposed to do? – lcd047 Jun 02 '15 at 08:38200
; ii) the 1st field and iii) the penultimate field. Why would you expect it to print the whole line? What output are you actually getting? – terdon Jun 02 '15 at 09:49