[Chapter 16] 16.8 The ls -d Option
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:37:42Z

#

| Chapter 16 Where Did I Put That? |

## 16.8 The ls -d Option

If you give ls the pathname of a directory, ls lists the entries in the directory:

>     % ls -l /home/joanne
>     total 554
>     -rw-r--r--  1 joanne      15329 Oct  5 14:33 catalog
>     -rw-------  1 joanne      58381 Oct 10 09:08 mail
>        ...

With the -d option, ls lists the directory itself:

>     % ls -ld /home/joanne
>     drwxr-x--x  7 joanne       4608 Oct 10 10:13 /home/joanne

The -d option is especially handy when you're trying to list the names of some directories that match a wildcard. Compare the listing with and without the -d option:

>     % ls -Fd [a-c]*
>     arc/                    bm/                     ctrl/
>     atcat.c                 cdecl/
>     atl.c.Z                 cleanscript.c
>     % ls -F [a-c]*
>     atcat.c                 atl.c.Z                 cleanscript.c

>     arc:
>     BugsEtc.Z       arcadd.c        arcext.c.Z      arcmisc.c.Z
>        ...
>     bm:
>     Execute.c.Z     MakeDesc.c.Z    MkDescVec.c.Z   Search.c.Z
>        ...

To list only the directory names, see the tip in article 15.10.

- JP

16.7 ls Shortcuts: ll, lf, lg, etc. |  | 16.9 An Alias to List Recently Changed Files