在与bash进行回显时,某些值不会被复制
我想将所有这些内容回传到文件中:在与bash进行回显时,某些值不会被复制,bash,ubuntu,Bash,Ubuntu,我想将所有这些内容回传到文件中: echo "server { listen 80; server_name mydomain.com; root /srv/www/clients/; index index.html index.htm index.php; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_st
echo "server {
listen 80;
server_name mydomain.com;
root /srv/www/clients/;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/finance-error.log error;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
}" >> default
但所有包含美元符号的值(如$query\u string;或$document\u root$fastcgi\u script\u name;)都将被删除。是否有可能以某种方式转义,以便所有这些值也将保留到文件中 您可以使用单引号来防止参数扩展,也可以使用here doc:
cat <<'EOF' > default
$query_string
$document_root
$fastcgi_script_name
EOF
cat>默认值(如果要追加)。请注意如何引用'EOF'
来防止参数扩展。您应该使用单引号来防止参数扩展,或者可以使用here doc:
cat <<'EOF' > default
$query_string
$document_root
$fastcgi_script_name
EOF
cat>默认值(如果要追加)。请注意,'EOF'
是如何被引用以防止参数扩展的。使用单引号而不是双引号使用单引号而不是双引号,并使用@RanyAlbegWein我确实想过要提到这一点,但这会吞噬所有前导选项卡。不过,它可以很好地处理空格缩进的代码!哦,我不知道。谢谢:-)好吧,也许一个猫默认值
可以用于OP。使用@RanyAlbegWein我确实想过要提到这一点,但这会吞噬所有的前导标签。不过,它可以很好地处理空格缩进的代码!哦,我不知道。谢谢:-)好吧,也许对于OP来说,cat默认值可以。