interface.txt 内容如下:
root@hadoop:/opt/dfp/bak_interface# cat interface.txt
I180013
I180012
I180011
A300003
A100003
脚本如下:
#!/bin/bash
time=$(date -d "-2 day" +%Y%m%d)
while read line
do
cd /opt/dfp/bak_interface/20210301
line1=$(ls -l | grep "$line$time.\{1,50\}.AVL" | wc -l)
for((i=1;i<=${line1};i+=1))
do
cp /opt/dfp/bak_interface/20210301/${line}${time}0000${i}.AVL /opt/dfp/load_interface/zwy/${line}${time}0000${i}.AVL.tmp
sleep 5
mv /opt/dfp/load_interface/zwy/${line}${time}0000${i}.AVL.tmp /opt/dfp/load_interface/zwy/${line}${time}0000${i}.AVL
done
cp /opt/dfp/bak_interface/20210301/${line}${time}00001.CHK /opt/dfp/load_interface/zwy/${line}${time}00001.CHK
done < /opt/dfp/bak_interface/interface.txt
执行效果如下: