Often you may need to find out how much disk space a file or folder (files inside the folder) occupies. This helps you to understand disk usage, remove unwanted files, and optimize disk usage.
Find File or Folder Size Using Terminal
To find the size of a file or a folder on Mac and Linux, use the command du
. It stands for disk usage. This command finds out the size of a single file or the size of all files recursively (including sub-directories) in a given folder. Since this command looks at all the files recursively, it may take a while to execute the command.
# Option h for human readable output and option s is for single line summary. # Neat and clean output. du -hs <folder-path> # Use only option h when you want to see size of files and sub-directories du -h <folder-path> # Use option x for showing grand total. It shows individual sizes as well. du -hc <folder-path>
Here is an example:
You may also use tree
command for this purpose. See more details in this article View Files in Tree Structure for Mac, Linux and Windows.
Find File or Folder Size Using UI
On Mac, right-click a file or a folder and click the menu Get Info
. This pops up a window with the details of the file or the folder. It shows the size of the file or the folder among other information.
Join our list to get instant access to new articles and weekly newsletter.