标签:
#!/bin/bash
#Big_User - find big disk space users in various direcotries
#Parameters for Script
#
CHECK_DIRECTORIES="/var/log /home" #direcotries to check
#
######################Main Script###########################
#
DATE=`date +%m%d%y` #Date for report file
exec > space_file_$DATA.rpt
#
#
echo "Top Ten Disk Space Usage" #Report header for whole report
echo "for $CHECK_DIRECTORIES Direcotries"
#
for DIR_CHECK in $CHECK_DIRECTORIES #loop to du directories
do
echo ""
echo "The $DID_CHECK Directory:" #Title header for each direcotry
#
#Create a listing of top ten disk space users
du -S $DIR_CHECK 2>/dev/null|sort -rn|sed ‘{11,$D;=}‘|sed ‘N;s/\n/ /‘|gawk ‘{printf $1":""\t" $2"\t" $3"\n"}‘
#
done
exec > /tmp/test.txt
标签:
原文地址:http://www.cnblogs.com/moss_tan_jun/p/5857582.html