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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
&means file descriptor1. So2>&1redirects standard error to whatever standard output currently points at, while2>1redirects standard error into a file called1.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.