技术小黑屋

How to Summarize Folder Size in Terminal

In this post, we will use the du command. This command does estimate file space usage; and It will summarize disk usage of each FILE, recursively for directories.

The description on the arguments we will use.

-h, —human-readable print sizes in human readable format (e.g., 1K 234M 2G) -s, —summarize display only a total for each argument

How to Summarize a single Folder Size

1
2
3
#Summarize the current folder size.
11:33:57-androidyue~/googlecode$ du -sh
85M   .

Summarize a certain folder size.

1
2
11:34:03-androidyue~/googlecode$ du -sh apps-for-android/
11M   apps-for-android/

How to summarize multiple folders sizes

1
2
3
4
5
6
11:35:17-androidyue~/googlecode$ ls | xargs du -sh
11M   apps-for-android
22M   depot_tools
740K  _gclient_src_fo4RrR
42M   gerrit
11M   reviewboard-read-only

More detailed information

ls – list directory contents
Description:List information about the FILEs (the current directory by default) xargs – build and execute command lines from standard input

Others





快来解锁最新版 Typora,新用户券后仅需 84 元!
如何便宜的购买 office 365 ?
新版赤友 NTFS 助手来袭,正版超低价