Advertisement
brianMc

Repeat IT

Feb 9th, 2017
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.62 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # repeatIT
  4. # Get's a color, phrase, and count
  5. # then prints phrase in the chosen color
  6. # x amount of times
  7. # uses looped option menu
  8. # By: Brian McCumber
  9.  
  10. clear
  11. nc='\033[0m' # No Color
  12. echo -e "Repeat IT\n"
  13. echo "Pick a color: 1-5. 5 is Exit"
  14.  
  15. OPTIONS="Red Green Yellow Blue Exit"
  16.  
  17. select opt in $OPTIONS; do
  18.     if [ "$opt" = "Red" ]; then
  19.         colr='\033[0;31m'
  20.         read -p "Type in phrase to repeat: " txt
  21.         read -p "How many times to repeat: " tms
  22.         for (( i = 1 ; i <= tms; i++ ))
  23.         do
  24.             printf "${colr}$txt  "
  25.             sleep .005       
  26.         done
  27.         printf "${nc}\n"
  28.     elif [ "$opt" = "Green" ]; then
  29.         colr='\033[0;32m'
  30.         read -p "Type in phrase to repeat: " txt
  31.         read -p "How many times to repeat: " tms
  32.         for (( i = 1 ; i <= tms; i++ ))
  33.         do
  34.             printf "${colr}$txt  "
  35.             sleep .005
  36.         done
  37.         printf "${nc}\n"
  38.     elif [ "$opt" = "Yellow" ]; then
  39.         colr='\033[0;33m'
  40.         read -p "Type in phrase to repeat: " txt
  41.         read -p "How many times to repeat: " tms
  42.         for (( i = 1 ; i <= tms; i++ ))
  43.         do
  44.             printf "${colr}$txt  "
  45.             sleep .005
  46.         done
  47.         printf "${nc}\n"
  48.     elif [ "$opt" = "Blue" ]; then
  49.         colr='\033[0;34m'
  50.         read -p "Type in phrase to repeat: " txt
  51.         read -p "How many times to repeat: " tms
  52.         for (( i = 1 ; i <= tms; i++ ))
  53.         do
  54.             printf "${colr}$txt  "
  55.             sleep .005
  56.         done
  57.         printf "${nc}\n"
  58.     elif [ "$opt" = "Exit" ]; then
  59.         clear
  60.         echo -e "Thanks for using Repeat IT, goodbye...\n"
  61.         exit
  62.     else
  63.         clear
  64.         echo -e "Repeat IT\n"
  65.         echo "You entered a Bad Option"
  66.         echo "Options: 1 = Red, 2 = Green, 3 = Yellow, 4 = Blue, 5 = Exit"
  67.     fi
  68. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement