Created
March 6, 2012 14:52
-
-
Save alexrinass/1986654 to your computer and use it in GitHub Desktop.
Redirect stdout and stderr to /dev/null for a script
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
# from http://stackoverflow.com/questions/314675/how-do-i-redirect-the-output-of-an-entire-shell-script-within-the-script-itself | |
# save stdout and stderr to file descriptors 3 and 4, then redirect them to "foo" | |
exec 3>&1 4>&2 >foo 2>&1 | |
# ... | |
# restore stdout and stderr | |
exec 1>&3 2>&4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment