Re: help with shell scripting!!
- From: SM Ryan <wyrmwif@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 26 Mar 2007 22:13:11 -0000
"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.
.
- Follow-Ups:
- Re: help with shell scripting!!
- From: Logan Shaw
- Re: help with shell scripting!!
- References:
- help with shell scripting!!
- From: seema
- help with shell scripting!!
- Prev by Date: Re: help with shell scripting!!
- Next by Date: Re: Process Synchronization using Pipes
- Previous by thread: Re: help with shell scripting!!
- Next by thread: Re: help with shell scripting!!
- Index(es):
Relevant Pages
|