If Selection statement

ok im kinda stuck i have a bash script with 4 options

1. Create Script
2. Show Script
3 . Delete script
4. Exit

how would i use an if statement for this? im not sure what test command i would use.
I know it would be like this (below) to display the script

if [ test command ]
then cat script1

or for the delete script

if [ test command ]
then rm script1

would i use -f?
or would i have to set a variable for each option 1,2,3,4?

I have set the variable as in the read command as

read -p "ENTER YOUR CHOICE: " SEL1

look into 'select' your shell man pages.

You don't really need to use "if" statements, you can use "case":

while true
do
	clear
	echo "Menu Options: "
	echo "     1. Create Script"
	echo "     2. Show Script"
	echo "     3. Delete script"
	echo "     4. Exit"
	echo " Choose: "
	read menuOpt
	
	case "${menuOpt}" in
		1) 	echo "Opt 1"
			break;;
		2) 	echo "Opt 2"
			break;;
		3) 	echo "Opt 3"
			break;;
		4) 	echo "Opt 4"
			echo "Exitting."
			exit;;
		*)	echo "Please, choose a valid option!";;
	esac
done

About the "rm -f" question, it depends on your needs! Generally, linux boxes have an alias that point rm to "rm -i" and if you want to bypass the alias, you can use "rm -f", so nothing will be asked when removing a file, otherwise, a message will be printed.

# echo a > test.txt
# alias rm="rm -i"
# rm test.txt
rm: remove regular file `test.txt'?
# rm -f test.txt
#

I hope it helps!

while true
do
    clear
    echo "Menu Options: "
    echo "     1. Create Script"
    echo "     2. Show Script"
    echo "     3. Delete script"
    echo "     4. Exit"
    echo " Choose: "
    read menuOpt
    
    case "${menuOpt}" in
        1)     echo "Enter name"
            break;;

Im having some trouble with this part, i get everything to show up but when it comes to "Choose" i press 1 and nothing happens. I also tried the read -p instead of a echo. Didnt work

And also can if statements be put into this loop to? Like after they enter a name i need them to choose a colour and if they enter or spel a color wrong they have to reenter it?

#!/bin/ksh

oldIFS=$IFS
IFS='
'

actions='Create Script
Show Script
Delete script
Exit'
PS3='Pick one of the above: '

select i in ${actions}
do
   case $REPLY in
      1)  echo 'Enter name' ;;
      2) cat script ;;
      3) rm script ;;
      4) exit 0 ;;
      "") print -u2 you must select one of the above [${actions}] ;;
   esac
   REPLY=''
done

ok i got everything to work

is there anyway which i can check the users input against a text file? in the loop?

im using a grep statement

grep -w "$cars" $carsfile

but it says no such file or directory tried the -f option to

Please, be more specific with examples.
You can always use *NIX utils to validate input: file-based or otherwise.
Depending on what your specifics are, you may use grep, sed, awk, perl,etc...

i put my example of grep, dont know exactly how to work it

if the value of the '$carsfile' variable point to the non-existing file, then it's what it is - the file you're trying to search doesn't exist.
You need to debug your script - include the 'set -x' at the top of your script and see the debug tracing.

In the above after pressing option 1, after everything is done in that part how would i get it to display all the options again so user can choose another option?

Replace all the break;; with ;;