Input not saving correctly in both files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Input not saving correctly in both files
# 1  
Old 04-18-2015
Input not saving correctly in both files

If the user inputs two variants separated by a comma, the below command is supposed to write both variants to the GJ-53.txt and then to out.txt. Both are written to the GJ-53.txt, however only one is written to out.txt and I'm not sure why. 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/$id.txt
        done
	add2text ${id}.txt
	cd 'C:' C:/Users/cmccabe/Desktop/Python27/
	printf "NM_004004.5:%s\n" "${variant}" >> c:/Users/cmccabe/Desktop/Python27/$id.txt >> c:/Users/cmccabe/Desktop/Python27/out.txt
	additional
}

The set -x
Code:
+ cd 'C:\Users\cmccabe\Desktop\annovar'
+ echo -n ''
+ cd C: C:/Users/cmccabe/Desktop/Python27/
+ echo -n ''
+ menu
+ true
+ printf '\n Welcome to target gene annotation and mutalyzer (v1), please make a
 selection from the MENU \n
        ==================================\n\n
        \t 1  GJB2 analysis\n
        \t 2  MECP2 analysis\n
        \t 3  Phox2B analysis\n
        \t 4  Syntax checker\n
        \t 5  Name checker\n
            \t 6  Position converter\n\n
        ==================================\n\n'

 Welcome to target gene annotation and mutalyzer (v1), please make a selection f
rom the MENU

        ==================================


                 1  GJB2 analysis

                 2  MECP2 analysis

                 3  Phox2B analysis

                 4  Syntax checker

                 5  Name checker

                 6  Position converter


        ==================================

+ printf '\t Your choice: '
         Your choice: + read menu_choice
1
+ case "$menu_choice" in
+ gjb2
+ printf '\n\n'


+ printf 'What is the id of the patient getting GJB2 analysis : '
What is the id of the patient getting GJB2 analysis : + read id
gj-53
+ printf 'Please enter the coding variant the following is an example'
Please enter the coding variant the following is an example+ echo ' c.274G>T'
 c.274G>T
+ printf 'variant(s), use a comma between multiple: '
variant(s), use a comma between multiple: + IFS=,
+ read -a variant
c.109G>A,c.101T>C
+ '[' -z gj-53 ']'
+ '[' gj-53 = end ']'
+ (( i=0 ))
+ (( i<2 ))
+ printf 'NM_004004.5:%s\n' 'c.109G>A'
+ (( i++ ))
+ (( i<2 ))
+ printf 'NM_004004.5:%s\n' 'c.101T>C'
+ (( i++ ))
+ (( i<2 ))
+ add2text gj-53.txt
+ cd 'C:\Users\cmccabe\Desktop\annovar'
+ echo gj-53.txt
+ cd C: C:/Users/cmccabe/Desktop/Python27/
+ printf 'NM_004004.5:%s\n' 'c.109G>A'
+ additional
+ printf '\n\n'


+ printf 'Are there additonal target gene patients to be analyzed?  Y/N '
Are there additonal target gene patients to be analyzed?  Y/N + read match_choic
e
n
+ case "$match_choice" in
+ id=gj-53
+ nomenclature
+ 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/Des
ktop/Python27/out_name.txt NameChecker
+ check
+ printf '\n\n'


Last edited by cmccabe; 04-18-2015 at 11:23 AM.. Reason: added set -x
# 2  
Old 04-18-2015
I figured it out. Thank you Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Saving files with file name as output

Hi, i need help with a file creation of an output program. I've got a program that with #find creates an output for each files in a directory. If i give this command : -o spec$(date -u +%Y%m%dt%H%M) it creates just one file, overwriting all the others since it is the creation date .... (2 Replies)
Discussion started by: Board27
2 Replies

2. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

3. Shell Programming and Scripting

saving all input name and store them as variables

Hi I want to write a script such that when executed, it will store all input as different variable, for eg ./store.sh name1 name2 name3 name4 will result in $1=name1 $2=name2 $3=name3 etc How do I do that? Thanks. (1 Reply)
Discussion started by: piynik
1 Replies

4. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

5. Shell Programming and Scripting

Saving files

Hi all, I need to save my files at c, d or any drive location via script. Requirement. Say for example i have 10 files at location /usr/bi/ci location. 10 files naming a.ksh b,ksh c.ksh and so on I want to save the files and its content at some location (any drive on local... (4 Replies)
Discussion started by: j_panky
4 Replies

6. Shell Programming and Scripting

Perl Script Not Reading Input Files Correctly

This is one of the strangest things that's happening to me. I'm writing a new Perl script that is trying to read a file. The file is originally in .mof format, but I also saved the contents into a .txt file. As a simple test, I wrote this: #!/user/bin/perl -w use strict; ... (3 Replies)
Discussion started by: kooshi
3 Replies

7. Shell Programming and Scripting

recursive saving of files and folders

Hi all I have a bash script, that loops through a folders files and all subfolders for .shtml files. It looks for a string and replaces it, creating a backup of the original file. This all works great, but I'd like, when the backup is done, that the files are then also created in their... (4 Replies)
Discussion started by: terrid
4 Replies

8. UNIX for Advanced & Expert Users

FTP is not transfering pdf files correctly

HI Experts, I have following code to FTP all pdf files from remote (win sever) to Linux box. function LsFiles(){ ftp -n -i -v $HT <<end_ftp user $USR $PASSWD cd $DIRNAME ls "-lrt *.pdf" bye end_ftp } LsFiles > list_of_files.txt function getFiles(){ ftp -n -i -v $HT <<end_ftp... (2 Replies)
Discussion started by: dipeshvshah
2 Replies

9. Shell Programming and Scripting

Reading specific contents from 1 input files and appending it to another input file

Hi guys, I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help. I have 2 input files (example given below) Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies

10. UNIX for Dummies Questions & Answers

Crontab keeps saving empty files of the job file.

Hey, MAILTO=cron@domain.ca */20 * * * * /usr/bin/wget http://list.domain.ca/admin/consume.php >/dev/nullthats what the crontab is setup todo, so basically every 20minutes it runs consume.php In my root directory, i'm getting files like this: consume.php consume.php1 consume.php2 i woke... (3 Replies)
Discussion started by: iarp
3 Replies
Login or Register to Ask a Question