使用perl将文件中的某些字符串替换为复杂的密码
我想在bash脚本中使用perl将文本文件中的某些字符串替换为可能包含各种特殊字符(密码)的其他字符串。包含特殊字符的变量来自环境,因此我无法知道它们 比如说使用perl将文件中的某些字符串替换为复杂的密码,perl,passwords,Perl,Passwords,我想在bash脚本中使用perl将文本文件中的某些字符串替换为可能包含各种特殊字符(密码)的其他字符串。包含特殊字符的变量来自环境,因此我无法知道它们 比如说 # pw comes from the environment and I cannot be sure about it's content pw='%$&/|some!\!smart%(]password' pw=${pw//:/\\:} perl -p -e "s:PASSWORD:$pw:" <<< "
# pw comes from the environment and I cannot be sure about it's content
pw='%$&/|some!\!smart%(]password'
pw=${pw//:/\\:}
perl -p -e "s:PASSWORD:$pw:" <<< "my pw is: PASSWORD" # this would come from a text file
# yields: my pw is: %PASSWORD/|some!!smart%(]password
#pw来自环境,我不能确定它的内容
pw='%$&/|一些!\!智能%(]密码'
pw=${pw/://\\:}
perl-p-e“s:PASSWORD:$pw:使用适当的:
pw='%$&/|一些!\!智能%(]密码'
导出pw=${pw/://\\:}
perl-pe的:密码:$ENV{pw}:'