读书人

bash shell notes

发布时间: 2013-02-06 14:02:21 作者: rapoo

bash shell notes:

#!/bin/bashconfig_file='xxxxx'tmp_file=/tmp/tempfile.$$function usage(){cat <<!usage: $(basename $0) optionsoptionsaaa       switch to aaabbb       switch to bbbccc       switch to ccc!    exit 9}cmd=$1if [ $# -eq 0 ]; then echo Required parameter '"'Environment'"' not set exit 1usage 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_filefi  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_filefiif [ "$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_filefi

?

读书人网 >操作系统

热点推荐