Shell 脚本元组+for循环

#!/bin/bash
#by:V log_dir=(/data/logs/anjubao_syncapi /data/logs/anjubao_wechat)
daytime=`date -d ' -1 day ' +%Y%m%d`
datatemp=/data/debugtemp if [ ! -d $datatemp ];then
mkdir -p $datatemp
fi for i in ${log_dir[@]}
do if [ ! -d $i ];then
echo 'log_dir error'
exit 0
fi logname1=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==1 {print $7}'`
logname2=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==2 {print $7}'`
logname3=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==3 {print $7}'`
logname4=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==4 {print $7}'`
logname5=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==5 {print $7}'`
logname6=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==6 {print $7}'`
logname7=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==7 {print $7}'`
logname8=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==8 {print $7}'`
tag=`echo $i|awk -F"/" '{print $4}'`
cd $i tar -czf $datatemp/ip175_$daytime-$tag.tar.gz $logname1 $logname2 $logname3 $logname4 $logname5 $logname6 $logname7 $logname8 if [ $? -eq 0 ];then
echo "hh"
上一篇:第五天:MySQL语法


下一篇:Android逆向 破解第一个Android程序