[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: shell script error



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 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 rescomp stanford edu>
System Administrator, Student Computing, Stanford University



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]