#!/bin/sh
#< Display home directory usage statistics for all users
#
# PURPOSE: Display formatted report showing home directory
# usage by user name. This script is based upon one
# found at www.linuxcommand.org, and has been modified
# for my site (which has some unconventional structure)
#
###############################################################
###############################################################
# MAIN
###############################################################
echo "--------------------------------"
echo "Home directory usage by username"
echo "--------------------------------"
format="%8s%10s%10s %-s\n"
printf "$format" "Dirs" "Files" "Blocks" "Directory"
printf "$format" "====" "=====" "======" "========="
# dir_list variable is the home directory root, in our case /disk1/*
# - for most uses, this will be /home/* or /export/home/*
# dir_list="/disk1/*"
dir_list="/home/*"
for home_dir in $dir_list; do
# site specific exclusion of directories you don't want to
# include in the report
# Just add another case branch for other excludes
case $home_dir in
"/home/exclude_me") : # exlclude
;;
"/home/me_too") : # exclude
;;
# REPORT EVERY OTHER USER
*) total_dirs=$(find $home_dir -type d | wc -l )
total_files=$(find $home_dir -type f | wc -l )
total_blocks=$(du -s $home_dir)
printf "$format" $total_dirs $total_files $total_blocks
;;
esac
done
exit 0
# End of script