Skip to content

Instantly share code, notes, and snippets.

@danidiaz
Last active December 17, 2015 08:18
Show Gist options
  • Save danidiaz/5579007 to your computer and use it in GitHub Desktop.
Save danidiaz/5579007 to your computer and use it in GitHub Desktop.
bash stuff
cat | grep foo
{ cat aabsdf.xx 2>&1 ; } 2>/dev/null
# http://stackoverflow.com/questions/2342826/how-to-pipe-stderr-and-not-stdout?rq=1
# http://www.gnu.org/software/bash/manual/bashref.html#Redirections
# http://mywiki.wooledge.org/Redirection
{ ls ; cat ; } | grep foo
{ echo "foo" ; cat ; } | grep foo
# the right part of a pipe only receives the stdout of the left part
# swaps stdin and stdout!
command 3>&1 1>&2 2>&3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment