shell - sed匹配某一行开头,替换整行内容

# sqlversion.php
sqlversion_file=${cur_dir}/web-admin/sql_version/sqlversion.php
sed -i "s#^\$db_host.*;#\$db_host='${DB_HOST}';#g" $sqlversion_file
sed -i "s#^\$db_user.*;#\$db_user='${DB_USER}';#g" $sqlversion_file
sed -i "s#^\$db_pwd.*;#\$db_pwd='${DB_PWD}';#g" $sqlversion_file
sed -i "s#^\$db_name.*;#\$db_name='${DB_NAME}';#g" $sqlversion_file
$db_host='';
$db_user='';
$db_pwd='';
$db_name='';
posted @ 2020-06-10 16:53  TBHacker  阅读(9899)  评论(0编辑  收藏  举报