I am very new to bash scripting. I am trying to create a script which creates a local txt file that is treated as a database. The commands the user can use is: quit, add, delete, printdb. How would I create a user prompt? If the user inputs quit how would I set up the quit function to quit the script and how would I pass the user input into the function?
I have done:
#!/bin/bash
func () {
echo -n "% "
read answer
}
if [ $answer != "quit" ] && [ $answer != "setdb" ] && [ $answer != "add" ] && [ $answer != "delete" ] && [
$answer != "printdb" ]
then
echo "Unrecognised command"
func
else
echo -n "%"
fi
#quit () {}
#setdb (){}
#add () {}
#delete () {}
#printdb () []
But it does not recognize if the commands are not valid.