待更新。
http://www.runoob.com/linux/linux-shell-io-redirections.html
http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_07
https://stackoverflow.com/questions/818255/in-the-shell-what-does-21-mean?rq=1
echo test > afile.txt
redirects stdout to afile.txt
. This is the same as doing
echo test 1> afile.txt
To redirect stderr, you do:
echo test 2> afile.txt
>&
is the syntax to redirect a stream to another file descriptor - 0 is stdin, 1 is stdout, and 2 is stderr.
You can redirect stdout to stderr by doing:
echo test 1>&2 # or echo test >&2
Or vice versa:
echo test 2>&1
So, in short... 2>
redirects stderr to an (unspecified) file, appending &1
redirects stderr to stdout.