Bourne shell question

Conor P. Cahill cpcahil at virtech.UUCP
Wed Oct 11 22:06:12 AEST 1989


In article <1943 at sactoh0.UUCP>, jak at sactoh0.UUCP (Jay A. Konigsberg) writes:

> 
> When the pipe into " pg " is removed it works ok, but I would like
> to keep the pg in the script.

Your problem is that pg always exits with a 0 (at least I could not get
any non-zero exit) and therefore the stuff to the right of the  || will never
be executed.  You could do the following:

(ls -l | grep "^d" || echo "There are no subdirectories" ) | pg

or you could re-write the script so it used more than 1 line:

	ls -l | grep "^d" > /tmp/sh$$

	if [ $? = 0 ]; then
		pg /tmp/sh$$
	else
		echo "There are no ..."
	fi

	rm /tmp/sh$$

-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.unix.questions mailing list