Change directory shell

 #!/bin/bash
echo -n "Enter number of sanger patients  : "; read id
perl -ne 'chomp; system ("perl table_annovar.pl $_ humandb/ -buildver hg19 -protocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -operation g,f,f,f,f,f -otherinfo")' < file.txt 

I have the above script that I would like to add a change directory line to.

 cd "C:\Users\cmccabe\Desktop\annovar" 

can that just be added in the line after the echo? Thanks :).

Maybe. Use single quotes so the \ are taken literally.

Try it. What happens?

 #!/bin/bash
echo -n "Enter number of sanger patients  : "; read id
cd 'C:\Users\cmccabe\Desktop\annovar'
perl -ne 'chomp; system ("perl table_annovar.pl $_ humandb/ -buildver hg19 -protocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -operation g,f,f,f,f,f -otherinfo")' < file.txt 
  bash ~/sanger.sh
Enter number of sanger patients  : 2
': not a valid identifierline 2: read: `id
: No such file or directoryne 3: cd: C:\Users\cmccabe\Desktop\annovar
/home/cmccabe/sanger.sh: line 4: file.txt: No such file or directory 

Maybe:

 while true
do
        printf "Enter ID  : " ; read id
        [ -z "$id" ] && break
        cd 'C:\Users\cmccabe\Desktop\annovar'
        perl -ne 'chomp; system ("perl table_annovar.pl $_ humandb/ -buildver hg19 -protocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -operation g,f,f,f,f,f -otherinfo")' < file.txt
done 

Thanks :).

Try removing the carriage returns from your file.

tr -d '\r' < windowstext > unixtext
1 Like

That fixed it, I always do that... force of habit I guess. Using linux more and more now though. Thanks :).

1 Like

We can tell. You're practically a regular over here now. Keep it up! :slight_smile:

I knew it the instant I saw your garbled error messages. They are garbled because the \r is sending the cursor to the beginning of the line without sending it down one line, causing partial overwrites.

1 Like

In Shell Script, u do that, i.e, only put the patch with "/" :

#!/bin/bash

cd /media/file1/file2/file3/file4

att.

________________________
Ramon Mayor Martins , MSc.