我目前有
echo -n "MySQL Database Name: "; read MyVar; sed -i 's/database_name_here/$MyVar/g' config.php
它部分工作,它提示我输入数据库名称。输入后,它会更新文件,但它仍然放置 $MyVar 而不是输入的内容。
echo -n "MySQL Database Name: "; read MyVar; echo "$Myvar"
^ 工作得很好。
有任何想法吗?
更新:
echo -n MySQL Database Name: ; read MyVar; sed -i s/database_name_here/$MyVar/g config.php
# ////
echo -n MySQL Username: ; read usr; sed -i s/username_here/$usr/g config.php
# ////
echo -n MySQL Password: ; read blackberg; sed -i s/password_here/$blackberg/g config.php
如果它只是 bash 上的一行,它可以工作并替换该值。但是当我有上述内容时,它会部分工作,但会用空白替换值。
有小费吗?