Reputation: 10813
echo -e "55 11\n25 11.0" | awk '$2 ~ /11/{print $1}'
I only want to match "11", and not "11.0"'s value 25. Any tips?
Upvotes: 2
Views: 5301
Reputation: 77085
Ensure last field does not contain a decimal point.
[jaypal:~/Temp] echo -e "55 11\n25 11.0" | awk '$NF!~/\./{print $1}'
55
Upvotes: 0
Reputation: 141780
Match the whole field:
% echo -e "55 11\n25 11.0" | awk '$2 ~ /^11$/{print $1}'
55
If you did want to match numerically, you should not use a regular expression, of course (your current one would also match 6119.42):
% echo -e "55 11\n25 11.0" | awk '$2 == 11 { print $1 }'
55
25
Upvotes: 5