Tuesday, December 16, 2008

Listing files in Linux sorted according to size


Have you ever felt the need to list the 10 files that takes the largest space in a specific directory? You might know that its pretty easy do that via GUI but believe me its the same thing when it comes to the Console also.

Here is how its done:
du -a (directory) | sort -n -r | head -n 10
This will list all the files in the directory specified, sorts them and lists the 10 files that takes up maximum size.

Easy, right?

0 comments:

 

A Linux Admin's WeBlog! Blak Magik is Designed by productive dreams for smashing magazine Bloggerized by Ipiet The Blog Full of Games © 2008