<p>Sometimes you will want to capture the output of a script into a log (maybe for later reference or use) while still viewing reali time what the script is logging. </p>
<p>Here's how you can do this with a simple linux command:</p>
<p><code>./my_awesome_script.sh 2>&1 | tee my_awesome_log.log</code></p>
<p>The first part of this command (2>&1) combines the error stream and the input steam into one which is then piped to the tee command. The tee command reads this input and writes it to both standard output and the my_awesome_log.log file, effectivelly duplicating the input.</p>
Get New Tutorials Delivered to Your Inbox
New tutorials will be sent to your Inbox once a week.