What's the difference of redirect an output us

2020-02-16 19:36发布

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

2条回答
霸刀☆藐视天下
2楼-- · 2020-02-16 19:59
  • > 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.
查看更多
Emotional °昔
3楼-- · 2020-02-16 20:13

1> (or >) is for stdout, the output of a command. 2> is for stderr, the error output of the command.

This page is a bit wordy, but has good explanations and examples of the different command combinations.

查看更多
登录 后发表回答