`

统计文件目录大小,文件个数

阅读更多
#!/bin/bash
info="/home/script/rec_ser.info"
res="/home/script/rec_ser.res"
src="/home/script"
if [ -d ${src} ];then
mkdir -p $src
fi
if [ ! -f $info ];then
touch $info
read -p "input host ip:" ip
read -p "input username:" user
read -p "input password:" pw
echo "${ip}:${user}:${pw}">>$info
fi
if [ ! -f $res ];then
touch $res
fi
y=$(date -d "today" +"%Y")
m=$(date -d "today" +"%m")
d=$(date -d "today" +"%d")
test=$[y-1]
test1=$[m+11]
echo $test $test1
if [ $m == 1 ];then
fy=$[y-1]
fm=$[m+11]
else
fy=$y
fm=$(echo $[m-1]|sed 's/^0\+//')
fi
echo $fm $fy
emts=$(cat $info)
echo "###################### ${fy} ${fm} ###############################" >> $res
for e in $emts;do
ipinfo=$(echo $e | awk -F ':' '{print $1}')
user=$(echo $e | awk -F ':' '{print $2}')
pw=$(echo $e | awk -F ':' '{print $3}')
mulu=$(echo $e | awk -F ':' '{print $4}')
mkdir -p /mnt/$ipinfo
mount -t cifs //$ipinfo$mulu /mnt/$ipinfo -o username=$user,password=$pw
echo "count ${ipinfo} size starting..........!"
size=$(du -sh /mnt/$ipinfo/$fy/$fm | awk '{print $1}')
echo "count ${ipinfo} file qualtity stating................!"
count=$(find /mnt/$ipinfo/$fy/$fm -type f |wc -l)
echo $ipinfo $size $count >> $res
umount //$ipinfo$mulu
done
echo "####################################################################" >> $res

/usr/sbin/sendmail -t <<EOF
From: rec_file count
To:yang.liu@91nbs.com
Subject:rec_file count
$(date -d "today" +"%Y%m%d")
$(cat /home/script/rec_ser.res)
EOF
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics