Created
April 28, 2010 17:41
-
-
Save jmar71n/382430 to your computer and use it in GitHub Desktop.
bash timer script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Section to timed between START an FINISH... | |
START=$SECONDS | |
echo "sleep 30s" | |
sleep 30s | |
FINISH=$SECONDS | |
timer () | |
{ | |
hrs="$((($FINISH - $START)/3600))hrs" | |
min="$(((($FINISH - $START)/60)%60))min" | |
sec="$((($FINISH - $START)%60))sec" | |
if [[ $(($FINISH - $START)) -gt 3600 ]]; then echo "$hrs, $min, $sec" | |
elif [[ $(($FINISH - $START)) -gt 60 ]]; then echo "$min, $sec" | |
else echo "$sec" | |
fi | |
} | |
echo -n "Elapsed time: "; timer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment