Path: utzoo!attcan!uunet!jarthur!usc!zaphod.mps.ohio-state.edu!mips!pacbell.com!pacbell!sactoh0!jak From: jak@sactoh0.SAC.CA.US (Jay A. Konigsberg) Newsgroups: comp.unix.questions Subject: Re: Can ls be made to only list directories? Message-ID: <3899@sactoh0.SAC.CA.US> Date: 6 Sep 90 04:22:14 GMT References: <90243.151817SML108@psuvm.psu.edu> <13725@smoke.BRL.MIL> <57@raysnec.UUCP> Organization: Sacramento Public Access Unix, Sacramento, Ca. Lines: 26 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.