Skip to content

Instantly share code, notes, and snippets.

@alexrinass
Created March 6, 2012 14:52
Show Gist options
  • Save alexrinass/1986654 to your computer and use it in GitHub Desktop.
Save alexrinass/1986654 to your computer and use it in GitHub Desktop.
Redirect stdout and stderr to /dev/null for a script
# 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