Can ls be made to only list directories?

Ray Shwake shwake at raysnec.UUCP
Wed Sep 5 05:19:30 AEST 1990


Create a shell script - call it dirs - then run "dirs *"

for i in `file $* | fgrep directory | sed 's/\([^:]*\):.*/\1/'`
do
	/bin/echo "$i \c"	# feel free to modify for built-in echo
done
echo

One can then run, for example:

	ls `dirs [a-z]*`

Variants are possible for other file types (like text, for example).
Of course, there are a few LS variants around supporting the -D option.
In which case, (well, you can finish this one yourself!)



More information about the Comp.unix.questions mailing list