shell脚本 生成.ok文件及相关操作

(1)遍历所有的zip文件,将有效的zip生成对应的.ok文件

#!/bin/bash

myPath="数据存放地址"

function echo_name(){ 
 for file in `ls $myPath *.zip` 
 do
  unzip -t $file
  if [ $? == 0 ];
    then
      if [ ! -f $file.ok ];
        then
           create_ok_file $file
      fi
  fi
 done 
} 
 
function create_ok_file(){
  echo "开始创建文件.ok文件:"$file
  touch $file.ok
  echo "创建文件.ok文件结束:"$file
} 
echo_name $1

(2)遍历所有的zip文件,对有效的zip【.ok文件】及zip文件进行转移

#!/bin/bash

myPath="数据存放地址"
tergetServerPath="目标用户@目标ip:目标路径"
bakPath="备份用户@备份ip:备份路径"

function echo_name(){ 
 #cd $myPath
 for file in `ls $myPath app_*.zip` 
 do 
  if test -e $myPath$file.ok
  then
     echo "the file is exit:"$myPath$file.ok
     echo "===============开始传输============="
     cd $myPath && scp -r $file.ok $tergetServerPath$file.ok
     cd $myPath && scp -r $file $tergetServerPath$file
     cd $myPath && scp -r $file.ok $bakPath$file.ok
     cd $myPath && scp -r $file $bakPath$file
     echo "copy文件及.ok文件结束:"$file
     echo ""
     echo "===============开始删除============="
     rm -rf $myPath$file.ok
     rm -rf $myPath$file
  else
     echo "the file is not exit:"$myPath$file.ok
  fi
 done 
} 

echo_name $myPath
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值