Created
July 31, 2013 20:04
-
-
Save putnamhill/6125638 to your computer and use it in GitHub Desktop.
A simple bash stop watch.
This file contains hidden or 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/bash | |
START=$(date +%s) | |
read -s -n1 -p $'Press a key when done.\n' | |
ELAPSED_SECONDS=$(bc <<< "scale=10; ($(date +%s) - $START)") | |
if [ $ELAPSED_SECONDS -gt 60 ]; then | |
ELAPSED_MINUTES=$((ELAPSED_SECONDS / 60)) | |
ELAPSED_SECONDS=$((ELAPSED_SECONDS - ELAPSED_MINUTES * 60)) | |
echo -n "$ELAPSED_MINUTES minutes " | |
fi | |
echo "$ELAPSED_SECONDS seconds" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment