我希望将stderr和stdout重定向到/dev/null。哪种方法是正确的,这些选项之间有区别吗?我在互联网上看到了两种语法: command &>/dev/null(无空格) command &> /dev/null(有空格) 提前感谢!
Bash允许在重定向运算符周围使用空格,因此两种形式都是有效的。但是,请注意,在更复杂的重定向运算符的各个部分之间不能使用空格,例如:command 2> /dev/null # ok command 2 > /dev/null # wrong, the operator is '2>' command 2> &1 # wrong, the operator is '2>&1'