on-internet
← Community

AWK comparision after sub

Stack Overflow ·

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.

Comments

Sign in or sign up to comment and upvote.

No comments yet.