Skip to content

Instantly share code, notes, and snippets.

@xtman
Created March 8, 2012 00:51
Show Gist options
  • Save xtman/1997654 to your computer and use it in GitHub Desktop.
Save xtman/1997654 to your computer and use it in GitHub Desktop.
stderr and stdout redirections
# redirect stdout to a file
cat 1.txt > r.txt
# redirect stderr to a file
grep "error" 1.log 2> r.txt
# redirect stdout to a stderr
grep * 1>&2
# redirect stderr to a stdout
grep * 2>&1
# redirect stderr and stdout to a file (often used in cron job)
grep * &> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment