Bourne shell question

Randal Schwartz merlyn at iwarp.intel.com
Thu Oct 12 14:13:14 AEST 1989


In article <1943 at sactoh0.UUCP>, jak at sactoh0 (Jay A. Konigsberg) writes:
| 
| I have a small shell script that I can't get quite right. What it
| is supposed to do is list subdirectories or the message "There are
| no subdirectories". The script is as follows:
| 
| 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.

Cheat.  Try something like:

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

'course, this puts "There are no.." through the pg, but who cares?
I said it was cheating.

Nope, I can't do it in Perl any shorter. :-)
-- 
/== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\
| on contract to Intel's iWarp project, Hillsboro, Oregon, USA, Sol III  |
| merlyn at iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn	         |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/



More information about the Comp.unix.questions mailing list