Saving both stdout and stderr while echoing to screen

As mentioned before, tee, a useful but horridly named utility, allows you to save stdout while echoing it to the screen. Sometimes, however, you need both stderr and stdout. Bash allows you to combine stderr and stdout by appending 2>&1 to your command. Thus

$ hadoop --jar $J/job.jar --job asdf 2>&1 | tee -a log.asdf.00

saves both stderr and stdout, correctly temporally interleaved, to the specified log file.

This entry was posted in bash. Bookmark the permalink.

One Response to Saving both stdout and stderr while echoing to screen

  1. Courtney says:

    Really interesting, thanks Earl!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>