Can ls be made to only list directories?

Randal Schwartz merlyn at iwarp.intel.com
Sat Sep 1 08:54:43 AEST 1990


In article <90243.151817SML108 at psuvm.psu.edu>, SML108 at psuvm (Scott the Great) writes:
| As the subject asks, is there a set of options which will limit
| ls to listing directories?

That's a bit ambiguous.  I'll try to answer all the variations...

(1) that's *all* it does anyway (taken literally). :-)  Does yours
send mail too? :-) :-)

(2) if you mean "list the directories by name, rather than listing the
contents of those directories", use the "-d" switch, as in:

	ls -d a*

lists all names in the current directory that begin with "a", regardless
of whether or not it's a directory (rather than listing the content
of the directories).

(3) if you mean "list *only* the directory names, and not their contents",
you can do that with echo (much faster), as in:

	echo a*/.

names all the directories in the current directory that start with "a".

(4) if you mean "list *only* directories along with their contents",
try a combination, as in:

	ls a*/.

lists all the directories in the current directory that start with "a",
along with their contents.

===

Hopefully, your meaning was in here somewhere.  If not, send me email.

Just another Unix hacker,
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn at iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/



More information about the Comp.unix.questions mailing list