Created
October 2, 2018 04:26
-
-
Save kamontat/4c1a37514a9a3daca26f358f99c64542 to your computer and use it in GitHub Desktop.
random group for Prof. Somnuk subject in Kasetsart University
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
#!/usr/bin/env bash | |
# shellcheck disable=SC1000 | |
# generate by v3.0.2 | |
# link (https://github.com/Template-generator/script-genrating/tree/v3.0.2) | |
# set -x #DEBUG - Display commands and their arguments as they are executed. | |
# set -v #VERBOSE - Display shell input lines as they are read. | |
# set -n #EVALUATE - Check syntax of the script but don't execute. | |
# requirement | |
# 1. Update folder path | |
# 2. install figlet and univers font | |
times=("09:00 - 09:45" "09:45 - 10:30" "10:30 - 11:15" "11:15 - 12:00" "13:00 - 13:45" "13:45 - 14:30" "14:30 - 15:15" "15:15 - 16:00" "16:00 - 16:45") | |
size=8 | |
exist=() | |
for ((i=0; i < size; i++)); do | |
rand="$(((RANDOM % size) + 1))" | |
if ! [[ "${exist[*]}" == *"$rand"* ]]; then | |
printf "Group name: " | |
read -r ans | |
figlet -f /tmp/univers -w 150 "$ans" | |
figlet -f /tmp/univers -w 150 "Group: $rand" | |
figlet -f /tmp/univers -w 150 "${times[rand-1]}" | |
echo "$ans --> group $rand" >>/tmp/result.txt | |
exist+=("$rand") | |
else | |
((i--)) | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment