About awk conditions

Hello,

Can you explain why in the first 2 commands the awk does not print anything? Is it looking of a specific format ?

Thanks.

$ echo 12a3 | awk '($1>=2) {print $1}' # prints nothing
$ echo 123a | awk '($1>=2) {print $1}' # prints nothing
$ echo a123 | awk '($1>=2) {print $1}'
a123
$ echo a123a | awk '($1>=2) {print $1}'
a123a
$ echo a12a3a | awk '($1>=2) {print $1}'
a12a3a

To compare the first numbers of the string with a numeric value you can use the int() function:

echo 12a3 | awk 'int($1) >= 2'