Sunday, April 3, 2011

stderr redirection to stdout

To redirect stderr to stdout we use 2 > &1. Why is it not just 2 > 1? why & is needed?

From stackoverflow
  • because your stream would be redirected to file named "1"

    chappar : so, why it is not &2 > &1. :-)
    Benny Wong : because 2 in that case is not ambiguous
  • Because 2>1 would redirect to a file named "1". The & symbol specifies a stream rather than a file. The & symbol is not necessary for the 2 because the 2 is always a stream inidcator

0 comments:

Post a Comment