3 ms·
It does not address timestamps, but set -x does this seamlessly without cluttering up your script. You can even run your script with sh -x script If you
by jpitz 4y ago
It does not address timestamps, but
set -x
does this seamlessly without cluttering up your script. You can even run your script with
sh -x script
If you didn't always want the logging output.
- memco 4y agoIn addition to set -x I have taken to wrapping my main entry point in some scripts where record keeping is helpful in a sub shell and pipe all output to a function that tees it's output to a log file after cleaning up escape sequences so I can generate a log file without having to annotate every line with some kind of wrapper: #!/usr/bin/env bash ( foo bar ) 2>&1 | print_and_log "$logfile"