shell脚本实现自动判断文件个数以及批量拷贝接口文件和检验文件到指定目录

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

执行效果如下:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_36588424/article/details/114310788
今日推荐