To get a list with the size of each item in a folder, we can use the
The -m argument will return the listing in megabytes (note that you can use -h for human readable, but it won’t sort correctly)
Now we will want to run this through the sort command, sorting in reverse order -r and numeric -n:
The only problem here is that we’ll get way too much output if there are a lot of files and folders, so we can either pipe it through the more command:du
command like this:du -sm *
The -m argument will return the listing in megabytes (note that you can use -h for human readable, but it won’t sort correctly)
Now we will want to run this through the sort command, sorting in reverse order -r and numeric -n:
du -sm * | sort -nr
du -sm * | sort -nr | more
Or we can just return the top 15 largest items:
du -sm * | sort -nr | head -15
This will return a listing something like this:
2907 Files1
993 Files2
38 Somefile.txt
Use this command to find the directories taking up the most space:
The du command along with the -k switch lists all directories and their respective size in kilobytes.
The sort command sorts the output so that the largest directory is shown first in the list. The -nr switch reverses the list and uses only numbers when sorting.
du -k | sort -nr | more
The du command along with the -k switch lists all directories and their respective size in kilobytes.
The sort command sorts the output so that the largest directory is shown first in the list. The -nr switch reverses the list and uses only numbers when sorting.
Here’s an example of the output:
For human-readable output use the following command:
12939451 .
1814892 ./abcdef
1219582 ./abcde
839586 ./abcd
718330 ./abc
695610 ./ab
690380 ./a
For human-readable output use the following command:
du -sh /*
0 comments:
Post a Comment