List File Sizes in Terminal
du -sh *
Sometimes it's helpful to list out the files and folders in a directory and show the size of each file/folder in a readable format. You can easily accomplish this with the following command:
du -sh *
This will list out the contents of the current directory and the size of each file/folder. Take a look at the following screenshot:
As you can see, in the example above we now know that the wallpapers
folder is the largest folder in the current directory weighing in at 355 Megabytes.
Listing out the current directory file sizes may help when you need to clean up file that are taking too much space, or it may help if you need to see which directory contains the most content.
If you wish to show the file sizes in order of Largest first, you can pipe the command to sort -rn
, like so:
du -sh * | sort -rn
This will now list the files in order by size.
It may be helpful to add these commands as an alias, or you can just store them in main memory (your mind).
No explanation generated yet.