[root@eccs_web home]# ls -hlS | head -11
-S 用文件和目录的大小排序。
-h或--human-readable 用"K","M","G"来显示文件和目录的大小。
备注:上面这种方法统计不能统计文件夹,只能比较文件的大小。
例如
[root@eccs_web usr]# ls -hlS
总用量 128K
dr-xr-xr-x. 2 root root 36K 11月 30 17:14 bin
dr-xr-xr-x. 58 root root 36K 11月 7 19:34 lib64
dr-xr-xr-x. 2 root root 12K 11月 30 17:14 sbin
drwxr-xr-x. 2 root root 4.0K 6月 28 2011 etc
drwxr-xr-x. 2 root root 4.0K 6月 28 2011 games
drwxr-xr-x. 53 root root 4.0K 11月 6 07:49 include
drwxr-xr-x 3 root root 4.0K 11月 6 07:50 java
使用du命令可以统计文件夹和文件的大小。
[root@eccs_web home]# du -sh * | sort -rn | head -11
822M mysql
437M tec
314M packages.tar.gz
40K lm
24K avb.bin
24K applaud
9.1M monitor
4.0K ifup.sh
4.0K ifdown.sh
sort -n: 以数字作为排序
sort -r: 反向排序
head -11:查看前11行(注意前面有个-)