我正在使用bash脚本试图阻止它尝试替换我的heredoc中的变量.如何将heredoc设置为A)转义变量名而不是解析它们或B)返回整个字符串不变?
cat > /etc/nginx/sites-available/default_php <<END server { listen 80 default; server_name _; root /var/www/$host; <--- $host is a problem child } END
当它完成将它注入文件时,我留下了这个:
server { listen 80 default; server_name _; root /var/www/; }
解决方法
从bash(1)手册页:
If any characters in word are
quoted,the delimiter is the result of quote removal on word,and the
lines in the here-document are not expanded.
cat > /etc/nginx/sites-available/default_php <<"END"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。