Created
March 9, 2021 23:35
-
-
Save kevinhooke/7c865d6f5c7e70b4f07af3948ae441ef to your computer and use it in GitHub Desktop.
stdin, stdout, stderr and redirection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 = stdin | |
1 = stdout | |
2 = stderr | |
#redirects stdout from command to file | |
command > file | |
#equivalent to | |
command 1> file | |
#if command writes errors to stderr, redirecting only stdout doesn't capture the errors | |
#this redirects stderr to errors.txt, stdout is left unchanged | |
command 2> errors.txt | |
#redirects stdout from command to file and then redirects stderr to current redirection for stdout (also to the file) | |
#note that this order is important | |
command > file 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment