Bourne shell question

Guangliang He ghe at nucthy.physics.orst.edu
Wed Oct 11 10:00:31 AEST 1989


Sorry to post it, but the mailer on our machine dosen't know the UUCP
domain.

In article <1943 at sactoh0.UUCP> jak at 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 at PHYSICS.ORST.EDU
          Department of Physics     |  BITNET:   hegl at ORSTVM.BITNET
          Weniger Hall 301          |
          Oregon State University   |
          Corvallis, OR 97331-6507  |  PHONE:    (503) 737-4631
=======================================================================



More information about the Comp.unix.questions mailing list