Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know the answer for some shells, e.g. with cmd.exe you can:

some.exe > out.txt 2>&1

How do you achieve the same for other shells (bash, ksh, tcsh, powershell, etc)?

share|improve this question

Fish shell

To redirect both standard output and standard error to the file all_output.txt, you can write:

echo Hello > all_output.txt ^&1
share|improve this answer
if piping output to next command, use 2>| instead: echo Hello 2>| less – Jeffrey04 Aug 14 '14 at 10:18

For csh and tcsh

some.exec >& out.txt
share|improve this answer
for tcsh, you also have some.exec |& less – boatcoder Jan 27 '11 at 22:21

In Powershell it is exactly the same:

2>&1      Sends errors to the        get-process none, powershell 2>&1
          success output stream.

(from about_Redirection).

In bash and ksh at least I also know it works this way.

It seems to be a common convention.

A quick way to find out about it is by opening the man page of the shell and do a search for &1 (with / and then typing &1). This rarely occurs in other contexts.

share|improve this answer

In bash you do exactly the same.

./some_exec > out 2>&1
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .