-
-
Save mike-bourgeous/bd58056617e1922ecba72abc58de94fc to your computer and use it in GitHub Desktop.
Swap stdout and stderr, log stderr to a file (BASH)
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 | |
test() { | |
echo "Standard out" | |
echo "Standard error" >&2 | |
} | |
tmpfile=`mktemp` | |
test 3>&1 4>&2 2>&3- 1>&4- | tee $tmpfile | |
cat $tmpfile | |
rm $tmpfile | |
# Result: | |
# Standard out | |
# Standard error | |
# Standard error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment