0
我想通过sed将日志格式添加到Docker容器内的nginx.conf中。我发出以下命令:单引号内的sed转义双引号
sed -i -e"s/client_max_body_size 100M/client_max_body_size 100M;\n\tlog_format specialLog '$remote_addr forwarded for $http_x_real_ip - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"'/" /etc/nginx/nginx.conf
但是它给我以下错误:
sed: -e expression #1, char 105: unterminated `s' command
我怎样才能逃避log_format命令?
试试这个http://stackoverflow.com/a/206963/4258817 – Mousey
我复制/经过你的命令,它对我来说工作正常。你的变量值是什么? – hogren
请参阅:https://unix.stackexchange.com/questions/168862/why-does-sed-outputs-char-53-unterminated-s-command您的命令是否有换行符?这可能是错误的。 –