diff --git a/bash/script_runtime.bash b/bash/script_runtime.bash new file mode 100644 index 0000000..b05f74c --- /dev/null +++ b/bash/script_runtime.bash @@ -0,0 +1,11 @@ +#!/bin/bash + +sleep 5000 + +secs=$SECONDS # utilise bash builtin SECONDS +hrs=$(( secs/3600 )); mins=$(( (secs-hrs*3600)/60 )); secs=$(( secs-hrs*3600-mins*60 )) # integer maths gives whole numbers + +printf 'Time spent: %02d:%02d:%02d\n' $hrs $mins $secs + +# output would be +# Time spent: 01:23:20