4

Tip #452   Command line stop watch

I wanted a simple (accurate to the second) stop watch when I was at the command line. So I did a quick one-liner.

START=$( date +%s ); while true; do CURRENT=$( date +%s ) ; echo $(( CURRENT-START )) ; sleep 1 ; echo -n ^[[A ; done

Note that the strange symbol after the 'echo -n' is the result of pressing 'CTRL-v' then the up arrow. If you want it to give you a 'split' just hit enter and it'll move onto the next line. Remember it's only second accurate so only one split per second will work. Hit 'CTRL-c' to stop it.
 
  • TAGS: