


Step 1: Check the Help Manual of the “du” Command (Optional)īefore using any command in Linux, it is always good to check its help manual so that you may get good knowledge about its correct usage. Method of Sorting the “du” Command Output by Size (Largest to Smallest)įor sorting the output of the “du” command by size (largest to smallest), i.e., in descending order, you will have to perform the following steps: However, you can also perform the very same method on a Ubuntu 20.04 system or a Debian 10 system. The option is right there, in the middle, Sorting Directories. I can finally see what movies, ahem, I mean presentations, I downloaded last. Well, I found the option now, which I want to share. Note: We have used a Linux Mint 20 machine to demonstrate this method. The sort rules only applied to files and I never took the time to figure it out. In today’s tutorial, we will be guiding you on the method of sorting the output of the “du” command in descending order, i.e., largest to smallest in Linux.

This is a very flexible command that can be combined with different parameters to get the desired output. We can also export the output in csv file and sort using size.“du” stands for disk usage, and as the name implies, this command is very useful in getting disk-related information in Linux. (please refer the below gif) FolderSize.ps1 script execution using Powershell The user can free up space simply by deleting the said. This categorisation helps the user to locate the trash files or empty folders no longer needed. Enter the Directory Name in $folderName and execute the script using powershell. It shows the size of all the folders in the whole PC in shape of a folder tree sorted by folder size. Save above script in ps1 format(like folderSize.ps1). $parentFolder = Get-ChildItem $folderName -recurse -force | Where-Object " -f ($eachChild.sum / 1MB) + "MB" #Enter the Directory Name which contains the list of folder (and nested folders)
