1 year ago
#326684
Fraca
AWK comparision after sub
I don't understand why AWK doesn't compare properly after using the sub() function.
When I run:
echo -e "LG:1000\nLG:3" | awk '{aa=$1; sub("LG:","",aa); if(aa <= 20) {print $0}}'
the output is LG:1000
instead should be LG:3
.
If I run this command:
echo -e "1000\n3" | awk '{aa=$1; sub("LG:","",aa); if(aa <= 20) {print $0}}
It works properly the output is 3
.
awk
casting
comparison-operators
0 Answers
Your Answer