Skip to content

Instantly share code, notes, and snippets.

@apinstein
Created October 12, 2011 16:34
Show Gist options
  • Save apinstein/1281741 to your computer and use it in GitHub Desktop.
Save apinstein/1281741 to your computer and use it in GitHub Desktop.
Redirecting STDOUT and STDERR for complex shell commands
#!/bin/sh
echo ">> STDOUT and STDERR"
(echo 'this is stdout' && this_is_stderr)
echo ">> STDERR only"
(echo 'this is stdout' && this_is_stderr) 1> /dev/null
echo ">> STDOUT only"
(echo 'this is stdout' && this_is_stderr) 2> /dev/null
echo ">> NOTHING"
(echo 'this is stdout' && this_is_stderr) > /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment