A Stopwatch on the Terminal

Using the bash builtin command time

You can just use the following terminal command to start the stopwatch:

time read -sn1

and press [Enter] when you want to take the time. As the output of the time command is a bit verbose, you may want the time command to only print the seconds and milliseconds:

TIMEFORMAT=%R; TIME=$( { time read -sn1 > /dev/null; } 2>&1 ); echo $TIME

Notes:

  • The TIMEFORMAT instruction tells the bash command time to print only the elapsed time in seconds. Please refer to the section TIMEFORMAT in the Bash Variables manual.

With a small GUI: stopwatch

On Debian (and derived distributions such as Ubuntu) you can install the little GUI stopwatch:

sudo apt-get install stopwatch

Resources

Comments