美文网首页
shell脚本--整理文件编号

shell脚本--整理文件编号

作者: w_dll | 来源:发表于2019-08-29 07:06 被阅读0次
#!/bin/bash
#date 0802
if [ ! -d './scripts' ];then
    mkdir ./scripts
fi
rm -rf ./scripts/*
find ./ -regex ".*/.*\.\(sql\|dmp\)" >1.txt
i=1
cat 1.txt | while read li
do
    dir_name=${li%/*}
    dir_name=${dir_name##*/}
    flag=`echo $dir_name |egrep  '仅|执行'`
    if [[ $flag ]];then
        if [ ! -d ./scripts/${dir_name} ];then
            mkdir ./scripts/${dir_name}
        fi
        cp "$li" "./scripts/${dir_name}/${i}_${li##*/}"
        ((++i))
    else
        cp "$li" "./scripts/${i}_${li##*/}"
        ((++i))
    fi
done
rm -f 1.txt

相关文章

网友评论

      本文标题:shell脚本--整理文件编号

      本文链接:https://www.haomeiwen.com/subject/qikbectx.html