Can ls be made to only list directories?
Jay A. Konigsberg
jak at sactoh0.SAC.CA.US
Thu Sep 6 14:22:14 AEST 1990
Come on people, this really is trivial! The basics are _simple_.
Just do `ls -l | grep "^d"`. However, here is a little shell script
I wrote a longgg time ago for splunking around the system.
You don't need awk, sed, ed or anything else so tough. If a script
can be done simple way, *do it in a simple way*.
------
# sdir - Get a sub-directory listing of your current directory
# Jay 9-15-88
(ls -l | grep "^d" || echo "There are no sub-directories")|pg
NOTE: The || works as an 'if' stmt for the times there aren't any
subdirectories and the parens are there to make sure the
output goes through `pg'.
The program lived for about 2 years as `ls -l | grep "^d"`
before getting upgraded and that was only done when I got
in the mood to hack something :-)
--
-------------------------------------------------------------
Jay @ SAC-UNIX, Sacramento, Ca. UUCP=...pacbell!sactoh0!jak
If something is worth doing, its worth doing correctly.
More information about the Comp.unix.questions
mailing list