0
我的工作如下形式的上的安装脚本:导出变量用反斜杠
# get username
echo "Please enter your oracle username:"
read -p "> " username
stty -echo
# get password
echo "Please enter your oracle password:"
read -r -p "> " password; echo
stty echo
# -- Create all text to output to config
finaluser=$usernamelabel$username
finalpassword=$passwordlabel$password
echo -e $finaluser"\n"$finalpassword > $configfile
问题是,如果像“Z \ 2Z”形式的密码,它输出到$ configfile为:
z^Bz
有没有简单的方法可以避免这种情况?
+1的'printf'版本第三条道路。还有更多的方法:'echo'$ finaluser“$'\ n'”$ finalpassword“> $ configfile'或'{echo”$ finaluser“;回声“$ finalpassword”; }> $ configfile' – 2011-03-23 02:21:10