Created
September 16, 2013 08:09
-
-
Save Aeramor/bd2f6c53b055ea106112 to your computer and use it in GitHub Desktop.
Shell stdout and stderr fancy tricks
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
Redirect stdout and stderr to a variable (so you can handle an error without printing to the console) | |
ERROR_MSG=$(redis-cli PING 2>&1) | |
Redirect only stdout to a variable | |
ERROR_MSG=$(redis-cli PING) | |
Redirect a whole block of commands to not print | |
{ | |
ERROR=$(redis-cli PING) | |
} >/dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment