Hi Sluggers, I am trying to convert (declare?) a string to an integer. the snippet goes something like this:
# grepstuff and totalerrors are functions earlier. ERRORNUM=`grepstuff $LOGTMP |totalerrors`
echo $STATUS echo "$ERRORNUM"
#this prints 54 which is the correct string value of $ERRORNUM
#if (( "ERRORNUM" >= 1 )) if [ "$ERRORNUM" != 0 ]
Oops!! :) That last message should've been:
Try (()) instead of [] like your commented line above. If that doesn't work then the following definitely will:
if [ $ERRONUM -ne 0 ]
See the man page for bash under CONDITIONAL EXPRESSIONS (capital for ease of searching the man page)
Fil -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html