Combine shell files

The script below is an attempt to combine 3 shells into 1.

The first part: match.sh
prompts the user for an id of a patient and runs a match script based on the response of "y" or "n". After completing the user is asked if there are additional patients, and based on "y" or "n" a certain action is followed.

The second part: convert2annovar.sh
prompts the user for an id of a patient and runs a conversion script based on the response of "y" or "n". After completing the user is asked if there are additional patients, and based on "y" or "n" a certain action is followed.

The third part: table_annovar
prompts the user for the type of analysis and runs a script based on the response of "y" or "n". After completing the user is asked if there are additional patients, and based on "y" or "n" a certain action is followed.

I attached the .sh file as well. Thank you :).

Question, does this run for you as expected?

+ ~ $ sh annovar.sh 
What is the id of the patient to be matched  : 3
': not a valid identifier `id
What panel: 3
': not a valid identifier `panel
annovar.sh: line 4: syntax error near unexpected token `$'in\r''
'nnovar.sh: line 4: `		case "$id" in

2 ~ $ sh annovar.sh 
What is the id of the patient to be matched  : a
': not a valid identifier `id
What panel: b
': not a valid identifier `panel
annovar.sh: line 4: syntax error near unexpected token `$'in\r''
'nnovar.sh: line 4: `		case "$id" in

2 ~ $ 

Already gave instructions how to avoid these in: http://www.unix.com/302922954-post2.html
The code looks very identical to your previous code.

Please show some more effort (than just copy paste previous thread into a single file), you seem quite capable looking at your perl lines.

Thank you

---------- Post updated at 22:54 ---------- Previous update was at 22:33 ----------

However, to give you a hint on how to avoid the 'goto's, here is a little example:

#!/bin/bash
# Loop menu example
# 2014.10.31 by sea
################### 
#
#	Variables
#
	show_menu=true
	menu=( "Entry One" "Another two" "All good things are three" )
	func_show() { # "MESSAGE STRING"
	# Prints passed argument
	# Returns nothing
		printf '\n\t%s\n\n' "$1"
	}
#
#	Display & Action
#
	clear
	while $show_menu
	do	printf '#----------------------#\n%s\n' "Please select your task:"
		select entry in "${menu[@]}" Back
		do	case "$entry" in
			Back)		show_menu=false
					;;
			"Entry One")	func_show "first code (index id 0) :: $entry"
					;;
			"${menu[2]}")	func_show "third code :: ${menu[${#menu[@]}-1]}"
					;;
			*)		func_show "anything else (index id 1) :: $entry"
					;;
			esac
			break
		done
	done

Hope this helps

The code is similar in that it is the same basic structure with additional functionality trying to be added. Being new to awk and learning I tried following your example (thank you for that):

 #!/bin/bash			
show_menu=true
	menu=( "[yY]" "[nN]" )
	func_show() { # "MESSAGE STRING"
	# Prints passed argument
	# Returns nothing
		printf '\n\t%s\n\n' "$1"
	}
#
#	Display & Action
#
	clear
	while $show_menu
	do	printf '#----------------------#\n%s\n' "Are there additonal patients to be matched"
		select entry in "${menu[@]}" Back
		do	case "$entry" in
			Back)		show_menu=false
					;;
			"[yY]")	func_show "perl -aF/\\t/ -lne 'BEGIN{%m=map{chomp;s/\cM|\cJ//g;$p=join("\t",(split/\t/)[4,5]);($p,$_)} <>;$m{"#CHROM\tINFO"}=$m{"Chr\tSegment Position"}};/SEGPOS=(\d+)/ || /\t(INFO)\t/ or next;$p=$F[0]."\t".$1;exists $m{$p} and print join("\t",$_,$m{$p})' ${id}_${panel}_${OMR}.txt < ${id}_${panel}_${OMR}_Filtered.vcf > ${id}_matched.vcf (index id 0) :: $entry"
					;;
			"${menu[2]}")	func_show "printf "Does the file need to be converted  : " ; read id :: ${menu[${#menu[@]}-1]}"
					;;
			*)		
			esac
			break
		done
	done 

This is just the first section of the script. If a "Y" response is given it will run a perl command, but if "N' is given it prompts the user and thats all. Is that correct? Thank you :).