I'm looking for a method to cast a string to an int in awk. I have the following which appears to be doing a string comparison
(note: field $5
is a percentage in one of two formats: 80%
or 9.0%
)
awk '{if (substr($5,1,(length($5)-1)) >= 90) ...
So, when I change it to:
awk '{if (substr($5,1,(length($5)-1))+0 >= 90+0 ) ...
It compares as I intended. Is this an appropriate cast? Is there a 'better' way to perform the cast?