Sunday, May 18, 2014

Linux - Script for showing size of subdirectories

So our log service is 98% full.
Thing is, iunno anything about our log server.
So I'm trying to figure out where all the junk is.
This is what I came up with:

 
SCRIPT:
for dir in $1/*/
do
    dir=${dir%*/}
    du -sh $1/${dir##*/}
done

USAGE:
./testScript.sh '/home'

OUTPUT:
8.0K    /home/appuser
4.0K    /home/logstash
32K     /home/ubuntu

No comments:

Post a Comment