Re: help with shell scripting!!



SM Ryan wrote:
You need to give arguments the test command will recognises,
such -n string, properly quote the arguments, and you should space
the brackets. In bourne shell it would look like
if [ -n "`echo $y | grep errors`" ]
then
echo "errors found"
fi

Or, bypass the test operation completely and use the exit code of
grep to indicate whether the string was found:

if echo "$y" | grep errors > /dev/null
then
echo "errors found"
fi

Or use the expr command:

if expr "$y" : '.*errors' > /dev/null
then
echo "errors found"
fi

Or, as someone else said, use a case statement (the most efficient way).

- Logan
.



Relevant Pages

  • Re: set user=%username%
    ... Your most recent feedback confirms that Windows is ... Type this: echo %MyName% ... > usertest=This is a long string. ...
    (microsoft.public.windows.server.general)
  • Re: its not the school home work
    ... I've learned a bit about strong quotes and think I realized when to ... the shell (such as in the $var, but also for the spaces (that ... echo "foo bar" ... you may say that $string does not appear in /list/ context so ...
    (comp.unix.shell)
  • Re: TRUE and FALSE are treated differently
    ... No -- you can't echo a boolean in PHP. ... If you look up the manual on type casting, you'll find that FALSE is cast ... to an empty string, and TRUE is cast to a non-empty string. ...
    (comp.lang.php)
  • Re: TRUE and FALSE are treated differently
    ... No -- you can't echo a boolean in PHP. ... the boolean is implicitly cast to a string. ... If you look up the manual on type casting, you'll find that FALSE is cast to an empty string, and TRUE is cast to a non-empty string. ...
    (comp.lang.php)
  • Re: TRUE and FALSE are treated differently
    ... No -- you can't echo a boolean in PHP. ... the boolean is implicitly cast to a string. ... If you look up the manual on type casting, you'll find that FALSE is cast to an empty string, and TRUE is cast to a non-empty string. ...
    (comp.lang.php)