Sometimes you come across a need to troubleshoot a misbehaving script or program things roll by on the screen too quickly.  The other day, I was troubleshooting a script that was blurting out an error and then continuing to open up a “dialog” screen which redraws the entire screen and clears the error.  I needed a way to send just the errors to a logfile.  If you are familiar with C programming, you’ll realize that there is STDOUT which writes to the console.  There is also STDERR which usually writes to the console but cannot be captured with a standard redirect such as:

program 1> logfile.txt

You’ll capture the STDOUT of that program but not any errors.  If you want just the errors, you’ll want to use:

program 2> logfile.txt

If you want to grab both the errors and the STDOUT, you can use:

program &> logfile.txt



If you like the content on this site, please support it by using this link to order from Amazon. You know you were going to go there and buy stuff anyhow so why not help me pay the hosting bill.