繁体   English   中英

sudo heredoc:bash:警告:第0行的here-document以文件结尾分隔(需要`EOF…EOF')

[英]sudo heredoc: bash: warning: here-document at line 0 delimited by end-of-file (wanted `EOF…EOF')

我的目标是使用sudo将内容写入另一个用户的xstartup文件。

但是我的尝试

sudo -iu user1 bash -lic 'cat > ~/.vnc/xstartup <<\EOF
...
EOF'

...结果是...

bash: warning: here-document at line 0 delimited by end-of-file (wanted `EOF...EOF')

但是嵌套的heredocs有效...

sudo -iu user1 bash -s <<\OUTER
cat > ~/.vnc/xstartup <<\EOF
...
EOF
OUTER

有没有建议在不嵌套heredocs的情况下完成sudo重定向的建议?

您有很多不必要的图层。

sudo -u user1 tee ~user1/.vnc/xstartup > /dev/null <<\EOF
...
EOF

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM