Can not remove file using rm command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can not remove file using rm command
# 15  
Old 03-28-2015
I'd recommend to trace the script portion before rm, where id is supposed to be set.
# 16  
Old 03-28-2015
It looks like the variable $id is being read but not set by the line in bold.... that might be the problem. How do I read and set this variable? Thank you Smilie.

Code:
 gjb2() {
    printf "\n\n"
    printf "What is the id of the patient getting GJB2 analysis  : "; read id
	 	
    printf "Enter variant(s): "; 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
	additionalg
}

# 17  
Old 03-28-2015
Check if id is empty?
Code:
printf "What is the id of the patient getting GJB2 analysis  : "; read id
[ -z "$id" ] && echo "Must provide an ID to work with!" && exit 1

hth
This User Gave Thanks to sea For This Post:
# 18  
Old 03-28-2015
Code:
+ printf 'What is the id of the patient getting GJB2 analysis  : '
What is the id of the patient getting GJB2 analysis  : + read id
del
+ '[' -z del ']'

Looks like id has a value but would read and set the id?:

Code:
printf "What is the id of the patient getting GJB2 analysis  : "; read id
[ -z "$id" ] && echo -n >> cd 'C:' C:/Users/cmccabe/Desktop/Python27/
[ -z "$id" ] && echo "Must provide an ID to work with!" && exit 1

Thank you Smilie.
# 19  
Old 03-28-2015
OK, trace everything from reading $id until the rm.
# 20  
Old 03-28-2015
I can do everything except for the rm and run the perl , but that may be related. Thank you Smilie.

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, 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  Exit\n\n
        ==================================\n\n'

 Welcome to target gene annotation, please make a selection from the MENU

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


                 1  GJB2 analysis

                 2  MECP2 analysis

                 3  Phox2B analysis

                 4  Exit


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

+ 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
del
+ '[' -z del ']'
+ printf 'Enter variant(s): '
Enter variant(s): + IFS=,
+ read -a variant
c.79G>A
+ '[' -z del ']'
+ '[' del = end ']'
+ (( i=0 ))
+ (( i<1 ))
+ printf 'NM_004004.5:%s\n' 'c.79G>A'
+ (( i++ ))
+ (( i<1 ))
+ add2text del.txt
+ cd 'C:\Users\cmccabe\Desktop\annovar'
+ echo del.txt
+ cd C: C:/Users/cmccabe/Desktop/Python27/
+ printf 'NM_004004.5:%s\n' 'c.79G>A'
+ additionalg
+ printf '\n\n'


+ printf 'Are there additonal GJB2 patients to be analyzed?  Y/N '
Are there additonal GJB2 patients to be analyzed?  Y/N + read match_choice
n
+ case "$match_choice" in
+ id=del
+ gjb2name
+ 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'


+ awk 'NR>1 { if ($2 ~ /^\(/ ) {$1=""; print "Found error: ", $0} else { sub(/.*
:/, "", $1); sub(/.*:/, "", $7); print "No error: " $1 "," $7}}' C:/Users/cmccab
e/Desktop/Python27/out_name.txt
No error: c.79G>A,p.(Val27Ile)
+ printf 'Is the variant correct?  Y/N '
Is the variant correct?  Y/N + read match_choice
y
+ case "$match_choice" in
+ id=del
+ position
+ 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/annovar/out_position.txt PositionConverter
+ parse
+ printf '\n\n'


+ cd 'C:\Users\cmccabe\Desktop\annovar'
+ perl -ne 'next if $. == 1;
            while (/\t*NC_(\d+)\.\S+g\.(\d+)(\S+)/g) {
                  # conditional parse
                ($num1, $num2, $common) = ($1, $2, $3);
                $num3 = $num2;
                if    ($common =~ /^([A-Z])>([A-Z])$/)   { ($ch1, $ch2) = ($1, $
2) }              # SNP
                elsif ($common =~ /^del([A-Z])$/)        { ($ch1, $ch2) = ($1, "
-") }             # deletion
                elsif ($common =~ /^ins([A-Z])$/)        { ($ch1, $ch2) = ("-",
$1) }             # insertion
                elsif ($common =~ /^_(\d+)del([A-Z]+)$/) { ($num3, $ch1, $ch2) =
 ($1, $2, "-") }  # multi deletion
                elsif ($common =~ /^_(\d+)ins([A-Z]+)$/) { ($num3, $ch1, $ch2) =
 ($1, "-", $2) }  # multi insertion
                printf ("%d\t%d\t%d\t%s\t%s\n", $num1, $num2, $num3, $ch1, $ch2)
;                 # output
                map {undef} ($num1, $num2, $num3, $common, $ch1, $ch2);
            }
           ' out_position.txt
+ annovar
+ printf '\n\n'


+ printf 'How many patients would you like to annotate  : '
How many patients would you like to annotate  : + read id
1
+ '[' -z 1 ']'
+ '[' 1 = end ']'
+ cd 'C:\Users\cmccabe\Desktop\annovar'
+ awk '{close(fname)} (getline fname<f)>0 {print>fname}' f=target.txt out_parse.
txt
++ perl -ne 'chomp; system ("perl table_annovar.pl $_ humandb/ -buildver hg19 -p
rotocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -opera
tion g,f,f,f,f,f -otherinfo")'
-----------------------------------------------------------------
NOTICE: Processing operation=g protocol=refGene

NOTICE: Running with system command <annotate_variation.pl -geneanno -buildver h
g19 -dbtype refGene -outfile del.txt.refGene -exonsort del.txt humandb/>
NOTICE: Reading gene annotation from humandb/hg19_refGene.txt ... Done with 251
transcripts (including 5 without coding sequence annotation) for 106 unique gene
s
NOTICE: Reading FASTA sequences from humandb/hg19_refGeneMrna.fa ... Done with 1
 sequences
NOTICE: Finished gene-based annotation on 1 genetic variants in del.txt
NOTICE: Output files were written to del.txt.refGene.variant_function, del.txt.r
efGene.exonic_variant_function
-----------------------------------------------------------------
NOTICE: Processing operation=f protocol=popfreq_all

NOTICE: Running system command <annotate_variation.pl -filter -dbtype popfreq_al
l -buildver hg19 -outfile del.txt del.txt humandb/ -otherinfo>
NOTICE: the --dbtype popfreq_all is assumed to be in generic ANNOVAR database fo
rmat
NOTICE: Variants matching filtering criteria are written to del.txt.hg19_popfreq
_all_dropped, other variants are written to del.txt.hg19_popfreq_all_filtered
NOTICE: Processing next batch with 1 unique variants in 1 input lines
NOTICE: Database index loaded. Total number of bins is 2816654 and the number of
 bins to be scanned is 1
NOTICE: Scanning filter database humandb/hg19_popfreq_all.txt...Done
-----------------------------------------------------------------
NOTICE: Processing operation=f protocol=common

NOTICE: Running system command <annotate_variation.pl -filter -dbtype common -bu
ildver hg19 -outfile del.txt del.txt humandb/>
NOTICE: the --dbtype common is assumed to be in generic ANNOVAR database format
NOTICE: Variants matching filtering criteria are written to del.txt.hg19_common_
dropped, other variants are written to del.txt.hg19_common_filtered
NOTICE: Processing next batch with 1 unique variants in 1 input lines
NOTICE: Scanning filter database humandb/hg19_common.txt...Done
-----------------------------------------------------------------
NOTICE: Processing operation=f protocol=clinvar

NOTICE: Running system command <annotate_variation.pl -filter -dbtype clinvar -b
uildver hg19 -outfile del.txt del.txt humandb/>
NOTICE: the --dbtype clinvar is assumed to be in generic ANNOVAR database format

NOTICE: Variants matching filtering criteria are written to del.txt.hg19_clinvar
_dropped, other variants are written to del.txt.hg19_clinvar_filtered
NOTICE: Processing next batch with 1 unique variants in 1 input lines
NOTICE: Scanning filter database humandb/hg19_clinvar.txt...Done
-----------------------------------------------------------------
NOTICE: Processing operation=f protocol=clinvarsubmit

NOTICE: Running system command <annotate_variation.pl -filter -dbtype clinvarsub
mit -buildver hg19 -outfile del.txt del.txt humandb/>
NOTICE: the --dbtype clinvarsubmit is assumed to be in generic ANNOVAR database
format
NOTICE: Variants matching filtering criteria are written to del.txt.hg19_clinvar
submit_dropped, other variants are written to del.txt.hg19_clinvarsubmit_filtere
d
NOTICE: Processing next batch with 1 unique variants in 1 input lines
NOTICE: Scanning filter database humandb/hg19_clinvarsubmit.txt...Done
-----------------------------------------------------------------
NOTICE: Processing operation=f protocol=clinvarreference

NOTICE: Running system command <annotate_variation.pl -filter -dbtype clinvarref
erence -buildver hg19 -outfile del.txt del.txt humandb/>
NOTICE: the --dbtype clinvarreference is assumed to be in generic ANNOVAR databa
se format
NOTICE: Variants matching filtering criteria are written to del.txt.hg19_clinvar
reference_dropped, other variants are written to del.txt.hg19_clinvarreference_f
iltered
NOTICE: Processing next batch with 1 unique variants in 1 input lines
NOTICE: Scanning filter database humandb/hg19_clinvarreference.txt...Done
-----------------------------------------------------------------
NOTICE: Multianno output file is written to del.txt.hg19_multianno.txt
+ printf 'The annotation is complete, would you like analyze additional target g
ene patients? Y/N '
The annotation is complete, would you like analyze additional target gene patien
ts? Y/N + read match_choice
n
+ case "$match_choice" in
+ id=
+ remove
+ printf '\n\n'


+ printf 'Removing old files, please wait '
Removing old files, please wait + rm 'C:\Users\cmccabe\Desktop\annovar\out_posit
ion.txt'
+ rm 'C:\Users\cmccabe\Desktop\annovar\out_parse.txt'
+ cd C:
+ rm c:/Users/cmccabe/Desktop/Python27/.txt
rm: cannot remove 'c:/Users/cmccabe/Desktop/Python27/.txt': No such file or dire
ctory
+ cd C:
+ rm c:/Users/cmccabe/Desktop/Python27/out_name.txt
+ printf '\n Old files removed, formatting for matrix '

 Old files removed, formatting for matrix + matrix
+ cd 'C:\Users\cmccabe\Desktop\annovar'
+ 'C:\Users\cmccabe\Desktop\annovar\matrix.pl'
c:\cygwin\home\cmccabe\bashparse.sh: line 157: .txt.hg19_multianno.txt: No such
file or directory
+ printf 'Process complete and new file saved in, Are there additional target ge
ne patients? Y/N '
Process complete and new file saved in, Are there additional target gene patient
s? Y/N + read match_choice

---------- Post updated at 10:12 AM ---------- Previous update was at 09:50 AM ----------

The below is what I am trying to remove. Is it not $id.txt in rm ?

Code:
printf "NM_004004.5:%s\n" ${variant[$i]} >> c:/Users/cmccabe/Desktop/Python27/$id.txt

# 21  
Old 03-28-2015
see?
Quote:
+ case "$match_choice" in
+ id=
+ remove
Just before "remove", id is set to "" (empty).
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need a command to remove the last word in the first line of a file

I have a eg file op.txt This is a cat This is a fat cat This is a fat black cat I want to remove only the word cat from the first alone .can somebody help. please do wrap your samples in CODE TAGS As per forum rules. (7 Replies)
Discussion started by: Sharks
7 Replies

2. Shell Programming and Scripting

Remove data from grep command using the pattern in the file

Hi, I writing a shell program to remove the data from output of the find which matches a list in a file I am using the below find command to get the list of files x=`find . -name test*.dat` the output of the find command is as follows test1.dat test2.dat test3.dat test4.dat... (4 Replies)
Discussion started by: pals70423
4 Replies

3. UNIX for Dummies Questions & Answers

Using sed command to remove multiple instances of repeating headers in one file?

Hi, I have catenated multiple output files (from a monte carlo run) into one big output file. Each individual file has it's own two line header. So when I catenate, there are multiple two line headers (of the same wording) within the big file. How do I use the sed command to search for the... (1 Reply)
Discussion started by: rebazon
1 Replies

4. Shell Programming and Scripting

sed command to remove the first field from a '|' delimited file

Hi I have a file with fields delimited by |. I need to remove the first field from the file. I tried cut but it just extracts that field. sample.output abc|100|name1 cde|200|name2 efg|300|name3 Output should be sample.output 100|name1 200|name2 300|name3 thanks Var (6 Replies)
Discussion started by: var285
6 Replies

5. Shell Programming and Scripting

Command to remove numbers from beginning of txt file

Hello. I have the following issue: my txt file has the following format: train/dr4/fklc0/sx175.txt 0 80282 Severe myopia contributed to Ron's inferiority complex. train/dr4/fklc0/sx355.txt 0 42906 Dolphins are intelligent marine mammals. train/dr4/fklc0/sa2.txt With the... (1 Reply)
Discussion started by: li_bi
1 Replies

6. UNIX for Dummies Questions & Answers

Command to remove First and Last line from a File

I have a file from which the Header and the Trailer lines need to be removed. They are confirmed to be the first and the last lines in the file. I have tried a few commands, but not successful yet. It needs to be implemented urgently, hence any help is greatly appreciated. Raghu ----------... (1 Reply)
Discussion started by: ragz_82
1 Replies

7. Shell Programming and Scripting

what command is used to remove the all text of the particular file.

Hi all... I want to delete the entire text of the file and want to make it zero byte.. would you please tell me the command for it. Thanks and regards Vijay sahu (4 Replies)
Discussion started by: vijays3
4 Replies

8. Shell Programming and Scripting

Command/Script to remove duplicate lines from the file?

Hello, Can anyone tell Command/Script to remove duplicate lines from the file? (2 Replies)
Discussion started by: Rahulpict
2 Replies

9. Shell Programming and Scripting

rm command not able to remove file

I have directory IXNPG7 under which i have seen file ads.c , ads.gif , ads.js and lots more with extension .html I tried to remove the Entire Directory with rm -Rf IXNPG7 but it is saying -- Directory Not empty can't remove Secondly i tried removing all the files first using rm *.*... (7 Replies)
Discussion started by: jambesh
7 Replies

10. UNIX for Dummies Questions & Answers

command to remove last record on file

Hi, First time on the forum. I have converted some files using the Unix to DOS command but need to strip off the last record that is generated from this conversion that contains just a ^Z. Is there any command that would accomplish this without having to do stream editing? (4 Replies)
Discussion started by: mheinen
4 Replies
Login or Register to Ask a Question