Skip to content

Instantly share code, notes, and snippets.

@Aeramor
Created September 16, 2013 08:09
Show Gist options
  • Save Aeramor/bd2f6c53b055ea106112 to your computer and use it in GitHub Desktop.
Save Aeramor/bd2f6c53b055ea106112 to your computer and use it in GitHub Desktop.
Shell stdout and stderr fancy tricks
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