Search code examples
linuxshellstdoutstderr

What does & mean in a shell code script redirect stderr to stdout (2>&1)?


I know that 2>&1 enables you redirecting stderr to wherever stdout.

  • but what is & means in this shell code? isn't it the append operator?
  • Is it possible to stream all the descriptors to stdout?

Solution

  • To be absolutely precise - the operator >& does merge descriptor noted before the operator to the descriptor written after the operator.

    So as mentioned above, the operator is >& and asking what does & in it mean doesn't make any sense.

    To your second question - I don't think it's possible with one operator / you'll need to repeat it for every operation you need.

    Standard/default descriptors for console app are:

    0 - stdin
    1 - stdout
    2 - stderr
    

    Any other can be defined by application...