Unhandled Exception
Unhandled Exception

Reputation: 1513

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?

Upvotes: 1

Views: 57

Answers (2)

kvantour
kvantour

Reputation: 26471

you could also do something like this:

$ shopt -s globstar
$ ls -ld **/

Having the option globstar set by default in your rc-files does not harm. The same accounts for extglob. globstar enables the recursive glob ** and extglob enables various other useful glob-expressions.

Upvotes: 0

William Pursell
William Pursell

Reputation: 212238

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.

Upvotes: 2

Related Questions