Ubuntu Linux has a rich set of commands for manipulating and accessing files. The du utility gives information on disk usage, and the sort utility can sort the results. Finally, we can run those results through the head command, which gives you the top 10 lines outputted through any other command. We’ll chain the commands together to get the output that we want.
First we’ll use the du -sm command to give the results in MB:
$ du -sm *
—- trimmed —
Now we can see that the results aren’t sorted, so we’ll sort them by the sort -nr command, which sorts by numerical value in reverse. Finally, we’ll run the results through head -10 to get the top 10 results:
This is the command we are going to run:
du -sm * | sort -nr | head -10
Here’s an example of the output:
$ du -sm * | sort -nr | head -10
Programmer by day, geek by night, The Geek, also known as Lowell Heddings, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on Google+ if you'd like.
- Published 11/26/06