【发布时间】:2015-11-06 07:54:36
【问题描述】:
我正在尝试通过 sed 在 Docker 容器内的 nginx.conf 中添加日志格式。我发出以下命令:
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 命令?
【问题讨论】:
-
我复制/粘贴了你的命令,它对我来说很好用。你的变量值是多少?
-
见这里:unix.stackexchange.com/questions/168862/… 你的命令中有换行符吗?那可能是错误的。