Displaying largest subdirectories in Linux

Unix — Dillon @ 2:38 pm

A quick script that can be triggered to email administrators (ie: using nagios) the largest subdirectories from a parent directory. Can also simply print the results to STDOUT.

Doesn’t work with the Solaris versions of `du’ and `sort’. :(

#!/bin/sh
TOP=20
DIR=/home/*
ADMIN=admin@host.com

if [ $1 == "-p" ]
then
du -sc $DIR|sort -rg|grep -v total|head -n $TOP
exit
fi

mail -s "**Space Utilization Report for `hostname`**" $ADMIN

0 Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2012 SQUARISM | powered by WordPress with Barecity