1

I tried to find information about the operator order in the statement

>&/dev/null

Is there any difference between >& and &>?

AdminBee
  • 22,803
  • 2
    @Freddy in bash, there's no difference between >&/dev/null and &>/dev/null, but there's a hell of a difference between >&path and >&number (as the OP's >&/dev/null and the >&2 you point to). You can find better duplicates by searching for >& with meta.stackexchange.com queries. –  Jan 19 '21 at 23:00
  • data.stackexchange.com queries, sorry ;-) –  Jan 19 '21 at 23:21
  • @UncleBilly Yes, you're right, I removed my close vote. Maybe someone else finds a better duplicate. – Freddy Jan 19 '21 at 23:40

1 Answers1

3

According to the manual 3.6.4 Redirecting Standard Output and Standard Error:

3.6.4 Redirecting Standard Output and Standard Error

This construct allows both the standard output (file descriptor 1) and the standard error output (file descriptor 2) to be redirected to the file whose name is the expansion of word.

There are two formats for redirecting standard output and standard error:

&>word

and

>&word

Of the two forms, the first is preferred. This is semantically equivalent to

>word 2>&1

When using the second form, word may not expand to a number or ‘-’. If it does, other redirection operators apply (see Duplicating File Descriptors below) for compatibility reasons.