2

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?
codeforester
  • 39,467
  • 16
  • 112
  • 140
0x90
  • 39,472
  • 36
  • 165
  • 245

2 Answers2

5

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...

Kamil Šrot
  • 2,141
  • 17
  • 19
1

When you write a 'console' program you have 2 different streams to send your output to, stdout and sterr.

stout is for normal output, sterr is to print error messages, by default both get printed on the console. There is not a clear division on what is "output" and what is "error", anyway if you want to redirect to a file, you can redirect output and errors to two different files - but if you want both on the same file (or pipe) your best bet is to redirect stderr to the stdout, and then dump the stdout to a file

For the meaning of the ampersand, please see http://en.wikipedia.org/wiki/Ampersand#Unix_shells

thedayofcondor
  • 3,860
  • 1
  • 19
  • 28