Skip to content

Instantly share code, notes, and snippets.

@mrandrewandrade
Last active August 29, 2015 14:05
Show Gist options
  • Save mrandrewandrade/f3103b0e84ce534d6cd3 to your computer and use it in GitHub Desktop.
Save mrandrewandrade/f3103b0e84ce534d6cd3 to your computer and use it in GitHub Desktop.
Write output of command to file using shell

All POSIX operating systems have 3 streams: stdin, stdout, and stderr. stdin is the input, which can accept the stdout or stderr. stdout is the primary output, which is redirected with >, >>, or |. stderr is the error output, which is handled separately so that any exceptions do not get passed to a command or written to a file that it might break; normally, this is sent to a log of some kind, or dumped directly, even when the stdout is redirected. To redirect both to the same place, use:

 command > out.txt 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment