Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For example, if I have a directory containing files file1 and file2, and a directory dir1, then "ls -l file1" will show details just for file1. Doing the same thing for dir1 will instead show the contents of dir1. Is there a way to treat dir1 like file1?

share|improve this question
up vote 25 down vote accepted

Use ls -l -d dir (-d will make it stop listing the contents of a directory). From the documentation:

-d, --directory

List just the names of directories, as with other types of files, rather than listing their contents. Do not follow symbolic links listed on the command line unless the --dereference-command-line (-H), --dereference (-L), or --dereference-command-line-symlink-to-dir options are specified.

share|improve this answer
7  
Merging single-character parameters also works for ls, so ls -ld dir and ls -dl dir and ls -l -d dir all work equally well. – Trey Hunner May 17 '10 at 7:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .