[TriLUG] OT - script help
Robert Ryals
rryals at tmio.com
Fri Jul 8 14:24:57 EDT 2005
Ryan Leathers wrote:
>Now there is an idea I hadn't thought of. Tom foolery with strings where one should use integers seems like a bad idea in general though. example:
>
>testvariable=5
>threshold=10
>
>if [ "$threshold" \< "$testvariable" ]
>then
> echo "Threshold $threshold is exceeded by value $testvariable" # or whatever
>fi
>
>The obvious problem is that when you compare values in ascii sort order
>10 is less than 5, so you don't get the result you want
>
>On the other hand, Warren's suggestion to match string length is probably a great way to go so long as the magic threshold value is always the flip from 99 to 100.
>
>
Use the -lt, -gt, -eq numeric test operators instead.
More information about the TriLUG
mailing list