Sunday, August 21, 2011

unix tricks - How to list and sort directories by size in Linux/Unix

How to list and sort directories by size in Linux/Unix
if you have a space problem on Linux - UNIX you may need to check which folders or file are taking more space . i tried this on Solaris it worked just fine .

Use this command to find the directories taking up the most space:

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:

12939451 . 1814892 ./abcdef 1219582 ./abcde 839586 ./abcd 718330 ./abc 695610 ./ab 690380 ./a






No comments:

Post a Comment