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 ]
        #then let STATUS="$STATUS but with errors"
        then STATUS="$STATUS but with errors"
        else echo status screwed
fi

The output of this looks like this:

Backup OK
54

What i really want to achieve is the arithmetic comparison. Grep outputs strings, but I want to convert the '54' outputted into an interger.
I have tried to make the declare -i function work, but everything I try gives me syntax errors.
Anyone have a nice way of converting the output of a grep + cut statement to an int? I have a number, just not an int.
bash version 2.05a-11


thanks in advance,

dave
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to