使用ls列出目录及其总大小 [英] Using ls to list directories and their total sizes

查看:163
本文介绍了使用ls列出目录及其总大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to use ls in Unix to list the total size of a sub-directory and all its contents as opposed to the usual 4K that (I assume) is just the directory file itself?

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

仔细阅读手册页后,我的脑袋空了.

After scouring the man pages I'm coming up empty.

推荐答案

尝试类似的方法:

du -sh *

的简短版本:

du --summarize --human-readable *

说明:

du: D isk U sage

Explanation:

du: Disk Usage

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

-s: Display a summary for each specified file. (Equivalent to -d 0)

-h:人类可读"输出.使用单位后缀: B yte, K ibibyte(KiB), M ebibyte(MiB), G ibibyte( GiB), T ebibyte(TiB)和 P ebibyte(PiB). (BASE2)

-h: "Human-readable" output. Use unit suffixes: Byte, Kibibyte (KiB), Mebibyte (MiB), Gibibyte (GiB), Tebibyte (TiB) and Pebibyte (PiB). (BASE2)

这篇关于使用ls列出目录及其总大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆