What's the difference of redirect an output using “>”, “&>”, “>&” and “2&>”?

后端 未结 2 1558
孤独总比滥情好
孤独总比滥情好 2020-12-23 10:46

What\'s the difference of redirect an output using >, &>, >& and 2&>?

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 11:08

    • > redirects stdout to a file
    • 2>& redirects file handle "2" (almost always stderr) to some other file handle (it's generally written as 2>&1, which redirects stderr to the same place as stdout).
    • &> and >& redirect both stdout and stderr to a file. It's normally written as &>file (or >&file). It's functionally the same as >file 2>&1.
    • 2> redirects output to file handle 2 (usually stderr) to a file.

提交回复
热议问题