It's not news that the shell turns
into every name in the current directory that starts
with a dot:
(I name my directory
that way), and so on - including
Also, many people know that the shell turns
into a list of the dot files in subdirectories:
-as well as
(If that surprises you, look at the wildcard pattern closely - or try it
on your account with the
What if you're trying to match just the subdirectory names, but not the
files in them?
The most direct way is:
and so on.
The dot (
) entry in each directory
is a link to the directory itself (
so you can use it wherever you use the directory name.
For example, to get a list of the names of your subdirectories, type:
ls -d */.
to list the names of directories, not their contents.)
With some C shells (but not all), you don't need the trailing dot (
ls -d */
(The shell passes the slashes (
So, if you use the
to put a slash after directory
names, the listing will show
slashes after each directory
When matching directory names that start with a dot,
the shells expand the
and pass the result to
really don't need the
is useful only when
(not the shell) to read a directory and list the entries in it.
You don't have to use
, of course.
command will show the same list more simply.
Here's another example: a Bourne shell loop that runs a command in each
subdirectory of your home directory:
for dir in $HOME/*/.
That doesn't take care of subdirectories
whose names begin with a dot,
shows a way to do that too.
shows a related trick that doesn't involve the shell or wildcards:
making a pathname
that will match only a directory.