Bourne shell question
David C. Raines
davr at hrtix.UUCP
Fri Oct 13 01:03:03 AEST 1989
In article <1943 at sactoh0.UUCP> jak at sactoh0.UUCP (Jay A. Konigsberg) writes:
>
>I have a small shell script that I can't get quite right. What it
>ls -l | grep "^d" | pg || echo "There are no subdirectories"
pg returns 'exit 0' whether there is any input or not, so the second half
of the 'or' is never executed. The following should do what you intended,
with the minor glitch that the 'no subdirectories' message also ends in
a page 'EOF:' prompt.
(ls -l | grep "^d" || echo "There are no subdirectories") | pg
Or you could write a more complex script that saved $? from the grep
command, etc.
>
>Thanks to all who respond.
You are welcome.
--
David Raines TCA 5 National Dr., Windsor Locks, CT 06096
UUCP: ...!uunet!hrtix!davr
More information about the Comp.unix.questions
mailing list