Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucsd!ogccse!orstcs!nucthy!ghe From: ghe@nucthy.physics.orst.edu (Guangliang He) Newsgroups: comp.unix.questions Subject: Re: Bourne shell question Keywords: pipe, logical 'or' and " pg ". Message-ID: <13022@orstcs.CS.ORST.EDU> Date: 11 Oct 89 00:00:31 GMT References: <1943@sactoh0.UUCP> Sender: usenet@orstcs.CS.ORST.EDU Reply-To: ghe@nucthy.PHYSICS.ORST.EDU (Guangliang He) Distribution: usa Organization: Dept. of Physics, Oregon State University Lines: 26 Sorry to post it, but the mailer on our machine dosen't know the UUCP domain. In article <1943@sactoh0.UUCP> jak@sactoh0.UUCP (Jay A. Konigsberg) writes: > > [deleted text here] > ls -l | grep "^d" | pg || echo "There are no subdirectories" > > When the pipe into " pg " is removed it works ok, but I would like > to keep the pg in the script. > [deleted text here] > When you have 'pg' in your script, the exit status of left hand side always 0. Without the 'pg', when 'grep' fails, the exit status of left hand side is a non zero value so the script goes to the right hand side of the || op. Then it echos "There ..." Hope it helps. ======================================================================= USMAIL: Guangliang He | INTERNET: ghe@PHYSICS.ORST.EDU Department of Physics | BITNET: hegl@ORSTVM.BITNET Weniger Hall 301 | Oregon State University | Corvallis, OR 97331-6507 | PHONE: (503) 737-4631 =======================================================================