Skip to content

Instantly share code, notes, and snippets.

@AnakinTrotter
Created April 21, 2022 02:49
Show Gist options
  • Save AnakinTrotter/f852dc1e681fc1f00a877cc5d22089b8 to your computer and use it in GitHub Desktop.
Save AnakinTrotter/f852dc1e681fc1f00a877cc5d22089b8 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "Welcome to typeracer!"
echo "Type the following text as fast as you can: "
echo ""
printf "" > random.txt
# get random words
shuf data.txt -n 10 >> random.txt
# declare array: arr
readarray -t arr < random.txt
cat random.txt | tr '\r\n' ' '
echo ""
echo ""
START_TIME=$(date +%s)
read input
END_TIME=$(date +%s)
ELAPSED_TIME=$((END_TIME - START_TIME))
RES=$((ELAPSED_TIME*30))
echo ""
echo "Words per minute:"
echo $RES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment