home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 16.7 ls Shortcuts: ll, lf, lg, etc. Chapter 16
Where Did I Put That?
Next: 16.9 An Alias to List Recently Changed Files
 

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


Previous: 16.7 ls Shortcuts: ll, lf, lg, etc. UNIX Power Tools Next: 16.9 An Alias to List Recently Changed Files
16.7 ls Shortcuts: ll, lf, lg, etc. Book Index 16.9 An Alias to List Recently Changed Files

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System










??????????????@Mail.ru