Is it possible to implement a stopwatch in bash? Here is my try:
https://github.com/jschnasse/stopwatch/blob/master/stopwatch
The script uses some interesting features like:
-
read -s -t.1 -n1 c
to read exactly one character (-n1) into a variable c only waiting 0.1 seconds for user input. sleep .1
to delay further processing for 0.1 secondssecs=$(printf "%1d\n" ${input: 0 : -9})
Create a digit from all but the last 9 characters lead by a zero if string is empty. This is used to separate seconds from a nano seconds.