是否有可能在Unix中使用ls列出子目录的总大小及其所有内容,而不是通常的4K(我假设)只是目录文件本身?

total 12K
drwxrwxr-x  6 *** *** 4.0K 2009-06-19 10:10 branches
drwxrwxr-x 13 *** *** 4.0K 2009-06-19 10:52 tags
drwxrwxr-x 16 *** *** 4.0K 2009-06-19 10:02 trunk

在翻遍了手册之后,我一无所获。


当前回答

du -h --max-depth=1 . | sort -n -r

其他回答

看一下du命令

试着这样做:

du -sh *

简写版:

du --summarize --human-readable *

解释:

du:磁盘使用率

-s:显示每个指定文件的摘要。(相当于-d 0)

-h: "人类可读"输出。使用单位后缀:Byte, Kibibyte (KiB), Mebibyte (MiB), Gibibyte (GiB), Tebibyte (TiB)和Pebibyte (PiB)。(BASE2)

Du -sch *在同一目录下。

du -h --max-depth=1 . | sort -n -r

使用实例递归显示当前目录的文件和子目录大小。

du -h .

要显示相同大小的信息,但不递归打印它们的子目录(可能是一个巨大的列表),只需使用——max-depth选项:

du -h --max-depth=1 .