What does the ampersand indicate in this bash command 1>&2
 Quick one, 2>&1 redirects stderr to stdout, but what does the ampersand mean?  I know if we had 2 > 1 it would output to a file named 1 , what does the ampersand do?  
它将文件描述符1复制到文件描述符2中.FD2是stderr,FD1是stdout,因此它将输出到stderr而不是stdout。
 2>&1 redirects standard error (file handle 2) to the same file that standard output (file handle 1) is currently going to.  
It's also a position-dependent thing so:
prog >x 2>&1 >y
 will actually send standard error to x and standard output to y as follows:  
x ;  x ;  y ;  The ampersand belongs to the "1", so the snippet really has three parts: "2", ">", "&1". They mean, respectively, "take the data from output stream 2 (which is standard error)", "redirect it", and the redirection target, which is output stream 1. So "&" here allows you to redirect to an existing stream, rather than to a file.
链接地址: http://www.djcxy.com/p/25604.html