批量替换多个相同Tomcat目录结构下的补丁文件

版权声明:原创文章,未经允许不得转载. https://blog.csdn.net/shengqianfeng/article/details/88407185
#!/bin/sh

if [ ! -n "$1" ] ;then
    echo "you have not input the first var!"
    exit
elif [ "$1" = "help" ];then
  echo "此脚本为admin系统补丁自动替换脚本,格式为:./adminPatch.sh 原文件admin路径下公共部分  替换文件admin路径下公共部分"
  echo " 比如: ./adminPatch.sh  /js/test.js  /opt/ipcc/zookeeper.out*"
  echo "O.K"
  exit
elif [ ! -n "$2" ] ;then
    echo "you have not input the second var!"
    exit
else
    echo "the word you input is $word"
fi


a="hello world!"
if [ "$SHELL" = "/bin/bash" ];then
  echo "your login shell is the bash \n"
  echo "SHELL is : $SHELL"
else
  echo your login shell is not bash but $SHELL 
fi
echo "a is ${a}!"
echo "=========================play is over!!! let's work!!!==============================================="
for i in /opt/ipcc/tomcat-enterprise-admin-ai*/admin
do
    echo "进入 :$i"
    for file in $i/$1*
    do
       mv $file $file.bak
       echo "重命名$file 为 $file.bak !"
       #echo $file
    done
    parentFolder=$i/$1
    parentFolder=${parentFolder%/*}
    echo $parentFolder
    cp $2* $parentFolder
    echo "拷贝 $2 到$parentFolder 完成!"   
    
done
echo "执行完毕!"

这个脚本主要是当有多个相同的项目部署在同一个机器上的时候,通过执行这个脚本可以备份替换指定目录下文件。

当项目比较多的时候这种还是挺有效率的!

猜你喜欢

转载自blog.csdn.net/shengqianfeng/article/details/88407185