我基本上是在尝试编写一个设置虚拟主机的脚本,我无法弄清楚将一段代码输出到根保护文件所需的语法,然后使输出静音。我一直在尝试这样的事情:
sudo tee /etc/apache2/other/$NAME.conf <<EOF
NameVirtualHost *:80
<Virtualhost *:80>
ServerName $NAME.dev
ServerAlias www.$NAME.dev
DocumentRoot /var/www/$NAME
<Directory "/var/www/$NAME">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
EOF &> /dev/null
但它不会抑制输出,它包含文件中的&> /dev/null
答案 0 :(得分:2)
此处文档与do-loop不同:重定向应出现在带有命令的行上:
sudo tee /etc/apache2/other/$NAME.conf &>/dev/null <<EOF
NameVirtualHost *:80
<Virtualhost *:80>
ServerName $NAME.dev
ServerAlias www.$NAME.dev
DocumentRoot /var/www/$NAME
<Directory "/var/www/$NAME">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
EOF