Sometimes we want to have a quick check the size of a specific directory in your current place from the terminal where you are working. Instead of opening Finder application – a common and unique file explorer on Mac, this need can be done by running the following command
du -sh <directory>
You can learn this command by running man du to see the other options as well as other usages. To remember this command, actually, du is short for “display disk usage statistics”.
If we don’t indicate a directory and -sh, the command will display the size of all directories recursively which are including all children directories. The size shows in bytes.
If you want to specify the directory level, the
-d<number> option could be useful which
<number> is the level. For example:
du -hd2 ~/Library/Android/
Notes: The following command is similar to the one above but only works on Linux
du -h --max-depth=2 ~/Library/Android/
In other words, both commands work on Linux.
Hopefully, these tricks would bring a convenient way for you to check a directory’s size.
All constructive comments are welcomed. If you are willing to contribute financial support for our website, please follow the instructions below.