tee
is a GNU tool to piggy back stout off of a pipe. The following example shows the basic pattern for using it, where the stout is printed to the terminal and written to a log file.
|
|
“teethis” script #
I frequently want to run shell scripts where I can see both the stdout and stderr immediately while preserving the output to refer to later. While the tee
command to do this is relatively simple, it can be a pain to type over and over again, so I created the following teethis script.
|
|
This simple script takes a bash script as the argument, and runs it while using tee to automatically save the stdout/stderr to a log file using the name of the script so that the log is easy to find.
|
|
Modifications that might also be frequently useful #
Append to output file, rather than overwriting
|
|
Run scripts with other interpreters, called like teethis python myscript.py
|
|
Execute shell commands, and include date/time
|
|