Skip to content

Instantly share code, notes, and snippets.

@hflamboauto1
Forked from magnetikonline/README.md
Created July 6, 2016 11:00
Show Gist options
  • Save hflamboauto1/6c1ec36041c7368fb02dba57c8923431 to your computer and use it in GitHub Desktop.
Save hflamboauto1/6c1ec36041c7368fb02dba57c8923431 to your computer and use it in GitHub Desktop.
Shell redirection cheatsheet.

Shell redirection cheatsheet

Examples

stdout to file

$ /bin/exec >/path/to/file.out

stderr to file

$ /bin/exec 2>/path/to/file.out

stdout to stderr

$ /bin/exec 1>&2

# or in most instances...

$ /bin/exec >&2
$ echo "Error: You did bad!" >&2

stderr to stdout

$ /bin/exec 2>&1

stdout and stderr to file

$ /bin/exec &>/path/to/file.out

# as an alternative
$ /bin/exec >/path/to/file.out 2>&1

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment