Using ls to list directories and their total sizes
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? IE
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.
Try something like:
du -sh *
short version of:
du --summary --human-readable *
Explanation:
du
: D isk U sage
-s
: Display a summary for each specified file. (Equivalent to -d 0
)
-h
: "Human-readable" output. Use unit suffixes: B yte, K ibibyte (KiB), M ebibyte (MiB), G ibibyte (GiB), T ebibyte (TiB) and P ebibyte (PiB). (BASE2)
du -sk * | sort -n
du -sk * | sort -n
will sort the folders by size. Helpful when looking to clear space..
du -sh * | sort -h
这将以人类可读格式显示。
链接地址: http://www.djcxy.com/p/78100.html上一篇: 如何检查符号链接是否存在
下一篇: 使用ls列出目录及其总大小