Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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'd like to be able to export the output (and error messages) of my cygwin terminal in a file, especially since I have to click a lot of buttons in order to "mark" the stuff in the cygwin terminal (and it's desirable to minimize the amount of clicking I do).

share|improve this question
up vote 4 down vote accepted

The stderr output of an executable can be redirected to a file with the following syntax:

mycommand 2> error.txt

If you want to redirect stdout (i.e. the regular program output) to the file, the command should be:

mycommand > output.txt

To redirect both the stderr and stdout output to the same file (similar to as seen on terminal), use:

mycommand > output_and_error.txt 2>&1
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.