【发布时间】:2017-05-28 08:01:47
【问题描述】:
我正在尝试将多行写入文本文件,如下所示:
cat <<EOT >> /etc/apache2/sites-available/eco.conf
<VirtualHost *:80>
ServerName eco.vagrant
DocumentRoot /var/www/eco/website/public
<Directory var/www/eco/website/public/>
Options FollowSymLinks
AllowOverride All
</Directory>
# Logging
ErrorLog /var/log/apache2/eco-error.log
LogLevel notice
CustomLog /var/log/apache2/eco-access.log combined
</VirtualHost>
EOT
但我得到bash: /etc/apache2/sites-available/o-eco.conf: Permission denied
所以我尝试了sudo cat...,但还是一样。
我很喜欢这样,而不是单行,因为它在 bash 脚本中,我可以清楚地看到将要写的内容的内容,例如缩进等。
我应该使用什么工具来以这种方式编写?或者我应该如何在这里使用 cat ?
【问题讨论】:
-
您没有写入文件的权限。语法无关紧要。
-
这个问题更适合超级用户或 Linux SE 站点。