I'm new to bash and have written this script to collect data then save it to an automated file. It runs fine til here but as I try to rerun the script to add another details it gives me errors.
#!/bin/bash
#This program helps the user to collect contact details.
clear
options="Add_User End_session"
echo "1. Add another user"
echo "2. End session"
echo -n "Enter Selection:"
read selection
echo ""
select opt in $options; do
if ["$opt" = "End Session" ]; then
echo done
exit
elif ["opt" = "Add another user"]; then
echo "Dear, user . This script will help you to collect data from people."
echo "Type the name:"
read name
echo "Type the age:"
read age
echo "Type the address:"
read address
echo "Type the gender:"
read gender
echo "Type the phone number:"
read phone number
echo "Type the email:"
read email
echo "Full Details"
echo "$name"
echo "$age"
echo "$address"
echo "$gender"
echo "$phone"
echo "$email"
echo "Name: $name" >> Datacollection.txt
echo "Age: $age" >> Datacollection.txt
echo "Address: $address" >> Datacollection.txt
echo "Gende: $gender" >> Datacollection.txt
echo "Phone Number: $phonenumber" >> Datacollection.txt
echo "E-mail Address: $email" >> Datacollection.txt
else
clear
echo bad option
fi
done
[
in an if statement is actually a command (typehelp '['
in a terminal), not just syntax. Like any other shell command, there needs to be a space between the command name and the first argument:if [ "$opt" ...