awk if percent % checking

hi everyone,

[root@]# cat a
a 10%
b 25.5%
c 91%
d 50%

[root@]# cat a | awk '$2 >= 90%; END {print $_}'
awk: $2 > 90%; END {print $_}
awk:         ^ syntax error
awk: each rule must have a pattern or an action part

how to do only print when 2nd coln >= 90%.
Thanks

awk '$2 >= 90 {print $1}' a

Use nawk with Solaris.

try..

awk 'int($2) > 90 ' file_name

Thanks, but your output is wrong, the output just "c".
posix is correct.

---------- Post updated at 02:54 AM ---------- Previous update was at 02:50 AM ----------

Thanks, i have another question:
how do i combine "awk 'int($2) > 90 ' a", with "sub {/c/, d}", and "sub {/ /, /\t/}"
means from the output of "c 90%", to "d 90%".

Please advice.
Thanks

The ouput is not wrong, not just the one you were expecting. "c" is the only value with which column 2 is > 90%. I though you wanted to display only the first column as you didn't tell anything about the expected result and there was a print statement in your code.

Indeed although int() is unecessary, awk is already doing this by default.

awk '$2 >= 90' a
awk '{if ( $2 >= 90 ) print $1," " $2 }' filename
awk '$2 >= 90{gsub("c","d",$1);print}' infile