Add 'bash/script_runtime.bash'
This commit is contained in:
11
bash/script_runtime.bash
Normal file
11
bash/script_runtime.bash
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user