bash null conditional
Robert Nichols
rnicholsNOSPAM at comcast.net
Tue Mar 31 04:45:32 UTC 2009
Craig White wrote:
> I'm not doing classwork...a little too old for that I think.
>
> I sort of did need the 'if' because I took the line out of a context
> from a bigger shell script that does more than this and reduced it down
> to the simplest form first for my trial and error and then for the list.
>
> Thanks though...I sort of had those in mind when I started but the
> context gets deeper - thus the
> if [ grep -c some_expression file -eq 0 ]; then ...
> did the job nicely.
Heck, if you want to simplify even further, don't bother with the '['
command and just use the return code from 'grep':
if grep -q some_expression file; then
echo "grep found something"
fi
--
Bob Nichols "NOSPAM" is really part of my email address.
Do NOT delete it.
More information about the users
mailing list