Created
January 31, 2018 01:45
-
-
Save zhaorui/7afbf328491b2c536ba3491d7796aaaf to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# redirect STDOUT to a file (note the single > -- this will truncate /tmp/outfile) | |
exec 1> /tmp/outfile | |
echo Now all STDOUT from each subsiquent command will | |
echo be redirected to /tmp/outfile | |
echo but not STDERR >&2 | |
# redirect STDERR to STDOUT and append (note the double >>) both to /tmp/outfile | |
exec 1>> /tmp/outfile 2>&1 | |
echo now we get STDERR too >&2 | |
# We can also turn off all output | |
echo 1>&- | |
echo 2>&- | |
echo Now you can\'t hear me! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment