Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Redirecting stdout/err correctly in bash
$ ruby -e '$stderr.puts "stderr"; $stdout.puts "stdout"' 2>&1 >tmp.txt && echo "tmp.txt>>>" && cat tmp.txt
stderr
tmp.txt>>>
stdout
$ ruby -e '$stderr.puts "stderr"; $stdout.puts "stdout"' >tmp.txt 2>&1 && echo "tmp.txt>>>" && cat tmp.txt
tmp.txt>>>
stderr
stdout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment