My command is:
exec &>/dev/null
What does this & and full command do here? I know it is being redirected to the bit-bucket.
bashexecio-redirectionshell
My command is:
exec &>/dev/null
What does this & and full command do here? I know it is being redirected to the bit-bucket.
Best Answer
It's
&>
, not just&
.In
bash
,&>
redirects both the standard output stream and the standard error stream somewhere.Hence,
utility &>/dev/null
is the same asutility >/dev/null 2>&1
.The command
exec &>/dev/null
redirects both output streams of the current shell to/dev/null
(i.e. it discards all output of the script from that point on, error or otherwise).The relevant part of the
bash
manual: