Special case to skip function in bash menu


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Special case to skip function in bash menu
# 1  
Old 10-27-2015
Special case to skip function in bash menu

In the bash menu below if the variant that is inputted is in the format NM_004004.3:c.274G>T the below works perfectly. My question is if the variant inputted isNM_004004.3:-c.274G>T or NM_004004.3:+c.274G>T then the code as is will throw an error due to a biological issue. Is it possible to to have variants that have either a -/+ in them skip the additional function and go straight to the nomenclature function? I apologize for any confusion I am not sure how to explain this, but basically if variants with a -/+ in them go to the additional function then they will error. I don't know if there can be a special case coded in or if there is a better way. Thank you Smilie.

Code:
 gjb2() {
    printf "\n\n"
    printf "What is the id of the patient getting GJB2 analysis : "; read id
	printf "Please enter the coding variant the following is an example"
	echo " c.274G>T"
	
    printf "variant(s), use a comma between multiple: "; IFS="," read -a variant
	        
        [ -z "$id" ] && printf "\n No ID supplied. Leaving match function." && sleep 2 && return
        [ "$id" = "end" ] && printf "\n Leaving match function." && sleep 2 && return

        for ((i=0; i<${#variant[@]}; i++))
              do printf "NM_004004.5:%s\n" ${variant[$i]} >> c:/Users/cmccabe/Desktop/Python27/out.txt
        done
	add2text ${id}.txt
	additional
}

Code:
nomenclature() {                 
 # run python NameChecker
    printf "\n\n"
	cd 'C:'
    C:/Users/cmccabe/Desktop/Python27/python.exe C:/Users/cmccabe/Desktop/Python27/run_batch_job.py C:/Users/cmccabe/Desktop/Python27/out.txt C:/Users/cmccabe/Desktop/Python27/out_name.txt NameChecker
   check
}

# 2  
Old 10-28-2015
I can't see a path to the "nomenclature" function, so any advice here is speculative. And, there may be multiple variants the user entered, what is to be done if one, or several, or all of those do have a +/- sign in them?

Anyhow, try parameter expansion to test for sign existence: [ "$variant" == "${variant#*[+-]}" ] && echo equal || echo different
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to skip if file not found in bash?

Hello, I have a question regarding while loop and existence of files. I am running under ubuntu 18.04 bionic, have around fifty video files inside the directory. script: for file in *.mp4 do /root/bin/ffmpeg -i $file \ -i $(basename "${file/.mp4}").bs.srt \ -i $(basename... (12 Replies)
Discussion started by: baris35
12 Replies

2. Shell Programming and Scripting

awk special parse case

I have a special case that awk could be used but I do not have the skill. Trying to create a final output file (indel_parse.txt) that is created from using some information from each of the two files (attached). parse rules: The header is skipped FNR>1 1. 4 zeros after the NC_ (not... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

Menu and case statement scripting

hi all i am trying to get help with writing a script using case statement to display menu as 1) Authentication log 2) System log 3) Messages 4) Dmesg 5) Boot log Q) Exit When selecting the menu by 1 or 2 or 3 o 4 or 5, it should display the last 10 lines of the log files, if... (3 Replies)
Discussion started by: renegade11
3 Replies

4. Shell Programming and Scripting

Need help in create menu with 3 sub menu using the case command

hi all i am a newbie to this is there any examples on creating a main menu with 3 sub menu main menu -> option a , b and c a menu -> option 1 ,2 and 3 b menu -> option 1 ,2 c menu -> option 1 ,2 i am getting headache as my code kept getting unexpected EOF ---------- Post... (0 Replies)
Discussion started by: chercm
0 Replies

5. Shell Programming and Scripting

Two columns output in simple case menu?

EDIT : System used : Any Linux distribution. Hello everyone, I m having quite a headache trying to figure out why I m having a 2 columns output in the following code : #!/bin/ksh menu_rotation() { #Variables CHOIX1="Rotation 1" CHOIX2="Rotation 2" CHOIX3="Rotation 3" ... (11 Replies)
Discussion started by: Sekullos
11 Replies

6. UNIX for Dummies Questions & Answers

menu + awk + while + case

the idea is to create script with menu and when option 1 or2 is pressed program should clear screan display info and get back to menu.... I managed some code but getting errors... #!/bin/bash choice1=ls -l|awk'{print $9 $1}' choice2= ls | wc -c choice3=exit while do clear echo "... (8 Replies)
Discussion started by: me.
8 Replies

7. UNIX for Dummies Questions & Answers

rename more files special case

hello all i have a big problems for me if i have more files as example test.ghrt.part01.rar test.ghrt.part02.rar test.ghrt.part03.rar test.ghrt.part04.rar test.ghrt.part05.rar test.ghrt.part06.rar test.ghrt.part07.rar test.ghrt.part08.rar test.ghrt.part09.rar test.ghrt.part10.rar... (13 Replies)
Discussion started by: ateya
13 Replies

8. Shell Programming and Scripting

My menu function

Below is my menu options code. It allows user to pick one of two option. I can get the first option to work, because if it is selected it just "breaks" and carries on with the script. What i want to know is if a user selects option two how do i get that option to ignore all the other script and... (6 Replies)
Discussion started by: amatuer_lee_3
6 Replies

9. SCO

Avoiding duplicates with some special case

Hi Gurus, I had a question regarding avoiding duplicates.i have a file abc.txt abc.txt ------- READER_1_1_1> HIER_28056 XML Reader: Error occurred while parsing:; line number ; column number READER_1_3_1> Sun Mar 23 23:52:48 2008 READER_1_3_1> HIER_28056 XML Reader: Error occurred while... (0 Replies)
Discussion started by: pssandeep
0 Replies

10. UNIX for Dummies Questions & Answers

how to delete whole directory in special case

Hello, Today, as a root user, i want to copy recursively all files and diretories in a source directory to a destination directory using the following command, cp -r /home/smith/* /home/bob/ However, I carelessly missed the '*' out when I executed the command. Now, i noticed a... (1 Reply)
Discussion started by: cy163
1 Replies
Login or Register to Ask a Question