When using redirection of this form 2 > &1, why is there an '&' before 1 but not before 2?
Asked
Active
Viewed 57 times
1 Answers
1
The >&
denotes a file descriptor duplication operation. 1
and 2
are the actual file descriptor references.
The subject of file descriptor duplication is explained in more detail here (and within that article's references):
Redirection using file descriptors - specific example

klode
- 44
&
as part of a filename-like thing (i.e.&1
meaning file descriptor 1); it's part of the>&
redirection operator. In fact,2 > &1
will get you an error message because there cannot be a space between>
and&
, and putting a space between2
and>&
means the2
is not part of the redirection operator, it's just an unrelated command argument, but you can put a space between>&
and1
, so2>& 1
will work fine. – Gordon Davisson Mar 03 '24 at 06:12&
on the left side always, even with a filename, e.g.&2>errors.out
? Wouldn't that be just an extra nuisance to write over2>errors.out
– ilkkachu Mar 03 '24 at 08:54