Shell循环处理

时间:2022-01-27 22:03:09
date=`echo $1 | tr -d '-'`
date1=`echo $1`
date_end=`get_date $2 +1 | sed 's/-//g'`
while [ 1 ]
do
date
echo $date1
if [ ! -d "/home/dataun/ETL_init/DATA/$date1/BICA/" ]
then
echo "开始创建"
mkdir -p "/home/dataun/ETL_init/DATA/$date1/BICA/"
fi
# rm -rf /home/dataun/ETL_init/DATA/"$date1"/BICA/ATFL$date
# rm -rf /home/dataun/ETL_init/DATA/"$date1"/BICA/ATFL$date
# rm -rf /home/dataun/ETL_init/DATA/"$date1"/BICA/ATFL$date
rm -rf /home/dataun/ETL_init/DATA/"$date1"/BICA/ATFL$date
for SUBDIR in zzzz zj zj_credit nb nj sh fz cz_15356900 cz_15355810 cz_15356926 cz_15357313
do
cd "/home/dataun/credit/test/cupsjnl/$date/"
if [ -f ./$SUBDIR/*ATFL ]
then
echo ./$SUBDIR/*ATFL
cd /home/dataun/credit/test/cupsjnl/$date/$SUBDIR
pwd
ls -ltr *ATFL
cat *ATFL >>"/home/dataun/ETL_init/DATA/$date1/BICA/ATFL$date"
else
echo "跳过的目录为"
echo $SUBDIR
continue
fi
done
echo $date
#-------------------------
date1=`get_date $date +1`
date=`echo $date1 | sed 's/-//g'`
if [ "$date" = "$date_end" ]
then
exit
fi
date
done