Re: help with shell scripting!!



"seema" <seema_coma@xxxxxxxxxxx> wrote:
# Hi all,
#
# I am new to shell programming, I want to do a string comparison, I am
# using tcsh here is the script I have
# written,
#
# #!/usr/local/bin/tcsh -f
#
# set y=" full of errors"
#
# if [`echo $y | grep errors`]

What you're doing here is probably
echo $y | grep errors
which write ' full of errors' to stdout and then insert stdout into the string
[ full of errors]
which becomes a call to 'test' with arguments 'full' 'of' 'errors]'
which is not any expression the test command recognizes.

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

--
SM Ryan http://www.rawbw.com/~wyrmwif/
God's a skeeball fanatic.
.



Relevant Pages