Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ginosko!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.unix.questions Subject: Re: Bourne shell question Keywords: pipe, logical 'or' and " pg ". Message-ID: <1259@virtech.UUCP> Date: 11 Oct 89 12:06:12 GMT References: <1943@sactoh0.UUCP> Distribution: usa Organization: Virtual Technologies Inc Lines: 29 In article <1943@sactoh0.UUCP>, jak@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 | +-----------------------------------------------------------------------+