It's clearly misaligned in your source -- not too mysterious. Maybe your text editor and the terminal disagree on how many spaces a tab is.
The shell has a built in menu tool which may make your life simpler:
clear ; printf "%s\n" "MENU" "========================"
# This is not just a menu, it's a loop. It keeps asking until you
# break out with 'break' or 'exit'.
select X in "Match patient" "Sanger analysis" "Exit"
do
case "$REPLY" in
1) match ;;
2) sanger ;;
3) exit ;;
esac
clear ; printf "%s\n" "MENU" "========================"
done
#!/bin/bash
# select menu with array example
# 2014.11.13 by sea
###################
#
# Variables
#
ar_menu=( "Menu entry 1" "Menu entry 2" "Menu entry 3" "Menu entry 4" )
#
# Display & Action
#
echo "Please select your action:"
select menu in Back "${ar_menu[@]}";do
echo "Selected: $menu"
case "$menu" in
Back) break ;;
"${ar_menu[0]}") echo "menu action 1" ;;
"${ar_menu[1]}") echo "menu action 2" ;;
"${ar_menu[2]}") echo "menu action 3" ;;
"${ar_menu[3]}") echo "menu action 4" ;;
esac
echo "Press [ENTER] to see the menu:"
done
Hope this helps to get started
EDIT:
Which modified could look like:
#!/bin/bash
#
# Variables
#
ar_menu=( "Match patient" "Sanger analysis" )
#
# Display & Action
#
echo "Please select your action:"
select menu in Back "${ar_menu[@]}";do
echo "Selected: $menu"
case "$menu" in
Back) break ;;
"${ar_menu[0]}") echo "Function to look up patient" ;;
"${ar_menu[1]}") echo "Do the sanger analyisis" ;;
*) echo "Invalid choice!!" ;;
esac
printf '%s\n' "-------------------" "Press [ENTER] to see the menu:"
done
And would output like:
sh 1.sh
Please select your action:
1) Back
2) Match patient
3) Sanger analysis
#? 2
Selected: Match patient
Function to look up patient
-------------------
Press [ENTER] to see the menu:
#? 3
Selected: Sanger analysis
Do the sanger analyisis
-------------------
Press [ENTER] to see the menu:
#? 4
Selected:
Invalid choice!!
-------------------
Press [ENTER] to see the menu:
#? 1
Selected: Back