Shell script to check and sort linux folder size
Hello everyone,
I'm trying to figure out what directories occupy the most disk space on my Linux vps, is there a command that can check and sort linux folder size? Thanks for any help It worked: du -sh /folder/* | sort -rh | head -n 5 Thanks Brian from magento explorer |
Hi,
Try du /folder | sort -nr | head |
As suggested, you can pipe several together to produce the result you want. Here is another variation:
Code:
du -sh /folder/* | sort -rh | head -n 5 Then it sorts in descending order, taking into account units like K, M, and G Then it shows just the top five offenders. See the manual pages for each of them for details. Code:
man du |
i inherited this script from somewhere:
Code:
#!/bin/sh |
This is one I inherited
Code:
du -sh * | tee /tmp/prova.txt | grep T | sort -rn ; grep G /tmp/prova.txt | sort -rn ; grep M /tmp/prova.txt | sort -rn ; grep K /tmp/prova.txt | sort -rn ; rm /tmp/prova.txt |
All times are GMT -5. The time now is 03:15 AM. |