Shell 操作练习2

#! /bin/sh
###############################
#          2013-11-19         #
#        author jackluo       #
#      net.webjoy@gmail.com   #
###############################
serverid=$1 #服务器的id
api_url=$2  #API服务器的url地址
api_file_path=/home/wwwroot/cy/application/config/server_lists_config.php #文件的url 路径
if [ -z "${serverid}" ] || [ -z "${api_url}" ];then
    echo "你要提供两个参数第一个是serverid第二个是api_url地址 不够"
    exit
fi
sed -i '$d'  ${api_file_path} #删除最后一行
echo "                        '${serverid}'=> array(
                                        'KEY' => "passed",
                                        'MAIL_GIFT_URL' => 'http://${api_url}/mailgift',
                                        'SEND_NOTICE_URL' => 'http://${api_url}/broadcast',
                                        'GM_TOOLS_URL' =>'http://${api_url}/ban'
                                  ),
        );" >> ${api_file_path}
sed -i 's/
//' ${api_file_path}
原文地址:https://www.cnblogs.com/jackluo/p/3431600.html