Search code examples
linuxrecursionls

List details of all directories and sub-directories only


Using the following works to show details of current directories.

> ls -ld *

Using the following works to show details of all directories and files in current location and sub-directories too.

> ls -lR *

But if I only wanted to view the details of only the current directories and only sub-directories, the following doesn't work.

> ls -lRd *

Why does -lR work and -ld work but not a combination of -lRd?

Is there an easy way to obtain this information?


Solution

  • I suspect you want something like:

    find . -type d -exec ls -ld {} +
    

    but it's not really clear to me what you mean when you say that ls -lr * works. Using * just expands to all names in the current directory, and -r just changes the order in which things are printed. ls -lrd * simply lists stats for all the entries in the current directory, and nothing is shown for the subdirectories because you've restricted the output with -d.