Wednesday, September 12, 2012

How to get list of top 10 files sorted by size

Sometimes you may need to find list of top 10 or 100 files within a directory or any of it's subdirectories sorted by size. It is quite easy to do that in linux. Do something similar to this:

du -a . | sort -n -r | head -n 10

The command above will return you top 10 files sorted by size in descending order from your current directory. If you want to get list of files from your "/opt" directory, sorted in a similar way, use the following command:
du -a /opt | sort -n -r | head -n 10

No comments:

Post a Comment