shell script error
Ian Ward Comfort
icomfort at rescomp.stanford.edu
Thu Dec 6 18:27:52 UTC 2007
On Dec 6, 2007, at 10:00 AM, Steven Buehler wrote:
> I hope this is the right list to ask this on. I am creating a
> shell script for something and the following line (whether run from
> the script or the command line) gives me an error:
> if [ ! -z /bin/cat /tmp/BACKUP/tmp | /bin/grep 'not accepted' ] ;
> then echo hi; else echo no; fi
On Dec 6, 2007, at 10:12 AM, <m.roth2006 at rcn.com> wrote:
> However, a simpler, cleaner version would be:
> if [ `grep -c "not accepted" /tmp/BACKUP/tmp` -gt 0 ]; then
> echo yep
> else
> echo nope
> fi
Or simpler yet, and much faster with large input:
if fgrep -q 'not accepted' /tmp/BACKUP/tmp; then
echo yes
else
echo no
fi
--
Ian Ward Comfort <icomfort at rescomp.stanford.edu>
System Administrator, Student Computing, Stanford University
More information about the redhat-list
mailing list