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

#!/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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值