简体   繁体   中英

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?

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM