#!/bin/bash
config_file='xxxxx'
tmp_file=/tmp/tempfile.$$
function usage()
{
cat <<!
usage: $(basename $0) options
options
aaa switch to aaa
bbb switch to bbb
ccc switch to ccc
!
exit 9
}
cmd=$1
if [ $# -eq 0 ]; then
echo Required parameter '"'Environment'"' not set
exit 1
usage
fi
if [ "$cmd" = "aaa" ]; then
cd ~/test/aaa/
cp $config_file $tmp_file
url="xxxxxxxxxxxxxx"
sed -i -e s/xxxxxxxxxx=.*/$url/ $tmp_file
cp $tmp_file $config_file
fi
if [ "$cmd" = "bbb" ]; then
cd ~/test/bbb/
cp $config_file $tmp_file
sed -i -e "s/shouldLogSql = System.properties.containsKey(\"logSql\")/shouldLogSql = true/" $tmp_file
cp $tmp_file $config_file
fi
if [ "$cmd" = "ccc" ]; then
cd ~/test/ccc/
cp $config_file $tmp_file
if grep "getEnvironment()\.toLowerCase()" $tmp_file; then
sed -i -e "s/getEnvironment()\.toLowerCase()/\"apac\"/" $tmp_file
fi
cp $tmp_file $config_file
fi
标签:tmp,bin,shell,tempfile,notes,file,bash From: https://blog.51cto.com/u_6174294/6207215