博客是我工作的好帮手,遇到困难就来博客找资料
分类: 系统运维
2015-05-29 18:00:12
arry=()
sql1="mysql语句; ";
ss1=$(mysql -u $DB_USER -h ${DB_IP} -p${DB_PASSWD} $DB_NAME -e "$sql1"|awk 'NR>1');
if [ -n "$ss1" ]
then
arry[t]=$ss1
else
arry[t]=0
fi
done
echo $i ${arry[*]}>>123456.txt;
STARTDAY=20150101
ENDDAY=20150430
sd=`date -d "$STARTDAY" +%s`
ed=`date -d "$ENDDAY" +%s`
DAYLEN=$(($(($ed-$sd))/86400))
echo $DAYLEN
sday=`date -d "$STARTDAY" +%Y-%m-%d`
syesday=`date -d "$sday + 1 day" +%Y-%m-%d`
crry=()
for((t=0;t<=$DAYLEN;t++));
do
itoday=`date +%Y%m%d -d "$sday +$t days"`
crry[t]=$itoday
done
echo "UID"" "${crry[*]}>>123456.txt;