2017-09-16 117 views
1

我想將stderr和stdout重定向到dev/null。 哪個是重定向的正確方法,這些選項之間有什麼區別? 我已經看到了互聯網可使用兩種語法:將stderr和stdout重定向到dev/null的語法

  1. command &>/dev/null(無空格)

  2. command &> /dev/null(含空格)提前

謝謝!

+1

他們是等價的。 –

回答

2

Bash允許redirection運算符周圍的空格,所以這兩個表單都是有效的。

這就是說,你不能更復雜的重定向操作符的部分,e.g之間用空格:

command 2> /dev/null # ok 
command 2 > /dev/null # wrong, the operator is '2>' 
command 2> &1   # wrong, the operator is '2>&1' 
相關問題