Let’s imagine you need to determine the size of several subdirectories.
In other words, you need the full aggregate size of each subdirectory, and in a simple numeric representation.
With this in mind, let’s move along.
If you were to issue an “ls” command in your current directory, you’d see the following.
$ ls
dir1 dir2 dir3
You’d see three subdirectories — dir1, dir2, and dir3. And because you’d like to know how big each is, you issue the following “du” (short for disk usage) command.
$ du -sh *
4.0K dir1
92.0K dir2
18.0K dir3
In short, you’d see that “dir1” is 4 kilobytes, “dir2” is 92 kilobytes, and “dir3” is 18 kilobytes.
And for clarity, descriptions of the flags used above (with the “du” command) are:
-s, –summarize = display only a total for each argument
-h, –human-readable = print sizes in human-readable format (e.g., 1K, 234M, 2G)