#!/bin/bash
logFile=/var/tmp/scan_`date "+%Y%m%d"`.txt
count=0
mountPoint="/"
bigfileScan(){
if [ -f $1 ]; then
echo "big file is "`ls -ltrh $1` 2>/dev/null
echo "big file is "`ls -ltrh $1` >> $logFile
echo "*********************************************************************************" >>$logFile
else
    if [ "$1" == "/" ]; then
    scandir=$1*
    else
    scandir=$1/*
        fi
        echo "checking directory" $scandir
        echo "checking directory" $scandir >>$logFile
    echo `du -skh $scandir 2>/dev/null |sort -n` >>$logFile
    echo "*********************************************************************************" >>$logFile
    bigdir=`du -sk $scandir 2>/dev/null |sort -n |tail -1 | awk '{print $2}'`
    echo "big directory is "$bigdir
    echo "*********************************************************************************" >>$logFile
    bigfileScan $bigdir
fi
}
main(){
echo "please check "$logFile" for details"
echo "*********************************************************************************" >>$logFile
echo Checking date is `date "+%Y%m%d"`>>$logFile
echo "*********************************************************************************" >>$logFile
sizeInfo=`df -h | awk -F'[ %]+' '{print $5":"$6}'|grep "/"`
for i in $sizeInfo
do
   count=`echo $i |cut -d : -f1`
   mountPoint=`echo $i |cut -d : -f2`
   if [ $count -gt 75 ];then
   echo $count"%   "$mountPoint>> $logFile
   echo "*********************************************************************************" >>$logFile
   bigfileScan $mountPoint
   fi
done

}
main