#!/bin/bash
path=/opt/AppServer/tomcat/webapps/$1/data/ddrt
sed -i 's/wl *= *disabled/wl=enabled/g' $path
sed -i 's/wu *= *disabled/wu=enabled/g' $path
保存为test.sh,假设你所说的文件名(那是文件夹,不是文件)为ABC,则运行
sh test.sh ABC
假设路径:path=/opt/AppServer/tomcat/webapps/SSSSSSSSSSS/data/ddrt
sh test.sh SSSSSSSSSSS
#!/bin/sh
#参数检查
if [ $# -ne 1 ]
then
echo "Usage: $0 filename"
exit
fi
#路径检查
path="/opt/AppServer/tomcat/webapps/$1/data"
if [ ! -d $path ]
then
echo "Path '$path' not exist!"
exit
fi
#文件检查
file="$path/ddrt"
if [ ! -f $file ]
then
echo "File '$file' not exist!"
exit
fi
#替换
sed -i "s/wl=disabled/wl=enabled/gi" $file
sed -i "s/wu=disabled/wu=enabled/gi" $file
希望能够帮助到你,你的好评是我前进的动力,谢谢!
#!/bin/bash
filename=$1
filepath=/opt/AppServer/tomcat/webapps/$filename/data
destfile=$filepath/ddrt
if [ -f "$destfile" ];then
sed -i 's/\(wl\|wu\)[ \t]*=[ \t]*disabled/\1 = enabled/g' $destfile
else
echo "not found $destfile"
fi