Shell output redirection

27 Nov 2008

You want to redirect the output of a command somewhere:

  • stdout to file

    $ your_command > output.txt
  • stderr to file

    $ your_command 2> output.txt
  • stdout to stderr

    $ your_command 1>&2
  • stderr to stdout

    $ your_command 2>&1
  • stdout and stderr to file

    $ your_command &> output.txt