Files
CodeSnippets/bash/script_runtime.bash
2022-07-01 10:18:56 +09:30

12 lines
294 B
Bash

#!/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