Skip to content

Instantly share code, notes, and snippets.

@regmicmahesh
Created September 11, 2025 14:10
Show Gist options
  • Save regmicmahesh/c21357e27290d9d86807f00cd110712e to your computer and use it in GitHub Desktop.
Save regmicmahesh/c21357e27290d9d86807f00cd110712e to your computer and use it in GitHub Desktop.
#!/bin/bash
DATA_FILE="S389242.txt"
echo "Welcome to the Raffle Draw Program."
while true
do
echo -n "Enter the number of People participating: "
read num_participants
if [ "$num_participants" -ge 1 ] && [ "$num_participants" -le 20 ]
then
break
else
echo "Number of people must be 1-20 (inclusive), Re-enter:"
fi
done
for (( i=1; i<=num_participants; i++ ))
do
echo ""
echo "--- Applicant $i of $num_participants ---"
while true
do
echo -n "Enter Name (max 30 chars): "
read name
if [ ${#name} -le 30 ]
then
break
else
echo "Name too Long - Re-enter (max 30 chars):"
fi
done
while true
do
echo -n "Enter State (note: this program is for people outside 'Canberra'): "
read state
if [ "${state,,}" != "canberra" ]
then
break
else
echo "Canberra is not allowed at this moment - Re-enter State:"
fi
done
echo "$name" >> "$DATA_FILE"
echo "$state" >> "$DATA_FILE"
echo "---------------------------------------------" >> "$DATA_FILE"
echo "Record saved for $name."
done
echo "All $num_participants Records have been Saved"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment