On Mon, 16 Feb 2004 22:50:11 +1100 David Kempe <[EMAIL PROTECTED]> wrote:
> Phil Scarratt wrote: > > Have you tried > > if [ $ERRORNUM -ge 1 ] > > > > Note the $ and the lack of quotes. This works for me in a backup script > > I have...(maybe I should check it first) > > > > #ERRORNUM=0 > ERRORNUM=`grepstuff $LOGTMP |totalerrors` > echo $STATUS > echo $ERRORNUM > #if (( ERRORNUM >= 1 )) > if [ $ERRORNUM -ge 1 ] > #then let STATUS="$STATUS but with errors" > then STATUS="$STATUS but with errors" > else echo status screwed > fi > > gives me: > 54 > : integer expression expected > status screwed > > which is what I expected :( > hrmm, maybe I should just learn perl instead :) Sorry, but that really looks like $ERRORNUM is not defined. instead of just echo $STATUS you should echo STATUS=$STATUS to be sure. Here's my tests. The -gt/-ge tests are not bothered by newlines. [EMAIL PROTECTED] mlh]$ E=54 [EMAIL PROTECTED] mlh]$ if [ $E -gt 0 ] > then > echo g > else > echo l > fi g [EMAIL PROTECTED] mlh]$ E=54' > ' [EMAIL PROTECTED] mlh]$ if [ $E -gt 0 ] ; then echo g; else echo l; fi g [EMAIL PROTECTED] mlh]$ if [ $undefined -gt 0 ] ; then echo g; else echo l; fi bash: [: -gt: unary operator expected l -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
