Reputation: 1821
I would like to know what the &
means in the statement:
2>&1 > /dev/null
It's redirecting standard error to standard output and then to Bitbucket, but what's &
in it?
Can I use it like the following?
2>1 >/dev/null
Upvotes: 15
Views: 30475
Reputation: 126243
The &
means file descriptor1. So 2>&1
redirects standard error to whatever standard output currently points at, while 2>1
redirects standard error into a file called 1
.
Also, the redirects happen in order. So if you say 2>&1 >/dev/null
, it redirects standard error to point at what standard output currently points at (which is probably a noop), then redirects stdout to /dev/null. You probably want >/dev/null 2>&1
.
1In the context of a file redirect -- when it is the next token immediately after a >
or <
. In other contexts it means something else.
Upvotes: 23