Tumble Confused Device

.oOo.

Bash better echo

Using echo in bash scripts is normal, but I like to have timestamps in my outputs. Also, I usually like to print stuff starting with a # so everything is a comment if I accidentally copy and paste into another terminal. Don’t ask how I get to this preference.

my_log() {
    echo [$(date +%H:%M:%S)] "$@"
}

Usually this goes into a one-liner, and I drop the my at the head of the function name and maybe use printf instead of echo, but, you get the point.

This allows me to run something like:

my_log This stuff will break if andrew touchs this code

And have a nice timestamped log… :-)

.oOo.