2011-06-25 25 views

回答

3

管道不是重定向,因此實際上重定向(其中只有一個在您的示例中)正按照您的想法進行處理。管道是最後一個單獨的東西。

3

原因是管道與重定向不一樣。重定向影響一個命令,而管道連接兩個命令。

3

fd 2指向fd 1指向的位置(即stdout)。在

command 2>&1 | less 

標準輸出已經在重定向生效之前指向管道!

如需更詳細的說明,請參見:

http://www.linuxtutorialblog.com/post/tutorial-the-best-tips-tricks-for-bash

# ... 
# Well, here's a thing you should remember: bash reads command statements from 
# the left to the right, but, before that, determines if there are multiple command 
# statements and in which way they are separated. Therefore, bash already read 
# and applied the "|" pipe symbol and stdout is already pointing to the pipe. 
# ... 
相關問題