Capture Errors from Command Line Tools
April 2026
TL;DR
Use this to capture errors along with regular output from command line tools:
Basic Capture
For example:
| If the file exists and is deleted, then it's file name is
output to the report-1.txt via STDOUT.
example.txtrm: example.txt: No such file or directorySeeing The Output
Running the above command doesn't output anything to
the terminal. You can add tee /dev/tty to see
the messages there as well.
| | Wrap Up
The 2>&1 looks weird to me. Totally worth it
to remeber though when trying to capture
the output of commands that use both STDOUT
and STDERR.
-a