Change directory shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change directory shell
# 1  
Old 10-28-2014
Change directory shell

Code:
 #!/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.

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

can that just be added in the line after the echo? Thanks Smilie.
# 2  
Old 10-28-2014
Maybe. Use single quotes so the \ are taken literally.

Try it. What happens?
# 3  
Old 10-28-2014
Code:
 #!/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

Code:
  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:
Code:
 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 Smilie.

Last edited by cmccabe; 10-28-2014 at 12:34 PM..
# 4  
Old 10-28-2014
Try removing the carriage returns from your file.

Code:
tr -d '\r' < windowstext > unixtext

This User Gave Thanks to Corona688 For This Post:
# 5  
Old 10-28-2014
That fixed it, I always do that... force of habit I guess. Using linux more and more now though. Thanks Smilie.
This User Gave Thanks to cmccabe For This Post:
# 6  
Old 10-28-2014
Quote:
Originally Posted by cmccabe
That fixed it, I always do that... force of habit I guess. Using linux more and more now though. Thanks Smilie.
We can tell. You're practically a regular over here now. Keep it up! Smilie
# 7  
Old 10-28-2014
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.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change directory within a bash shell script

Hi, I have been trying to execute the below command by changing directory and then copying contents of one directory to another by doing some file name manipulations in between. However this isnt working since as soon as the statement completes it goes back to the original folder. Can someone... (5 Replies)
Discussion started by: HikingLife
5 Replies

2. Shell Programming and Scripting

Change Directory

Hi All, There is a code like below in my script ############################################### ###Create Directories and Sub-Directories ############################################### dpdir=DP_FROM_${from}_TO_${to} mkdir $dpdir cd $dpdir mkdir AWQM WFCONTROLLER PROVCO PRISM ... (1 Reply)
Discussion started by: pvmanikandan
1 Replies

3. Shell Programming and Scripting

Change to directory and search some file in that directory in single command

I am trying to do the following task : export ENV=aaa export ENV_PATH=$(cd /apps | ls | grep $ENV) However, it's not working. What's the way to change to directory and search some file in that directory in single command Please help. (2 Replies)
Discussion started by: saurau
2 Replies

4. UNIX for Dummies Questions & Answers

How to change database directory to another directory?

Hi, I Installed mysql on my CentOS 6.2 Server. But when I tried to change the location of /var/lib/mysql to another directory. I can't start the mysql. Below is what I've done yum install mysql mysql-server mysql-devel mkdir /path/to/new/ cp -R /var/lib/mysql /path/to/new chown -R... (1 Reply)
Discussion started by: ganitolngyundre
1 Replies

5. Shell Programming and Scripting

How to change a directory in shell script?

HI, I need to change the working directory by using the shell script /Export/home/user_name I have to go one step back like /Export/home Please help on this.:confused: (3 Replies)
Discussion started by: thelakbe
3 Replies

6. Shell Programming and Scripting

directory change in shell script

Hi, I am trying to change the directory in my script, & want to check if the directory is present or not . Ex: cd /home/xyz/temp/logs if the logs directory is not present i want to show the error in script instead of shell script error. Can anybody please help me on the same Thx in... (2 Replies)
Discussion started by: vls1210
2 Replies

7. UNIX for Dummies Questions & Answers

Change Directory

I have a directory that is existing under my root dir of the FTP server. The DIR name is 'Software Patch'. I want to move in to that DIR to download some patches. But, when I issued a command 'cd SOftware Patch', the system said that it cannot find the dir 'Software'. I tried all possible ways like... (2 Replies)
Discussion started by: vskr72
2 Replies

8. Linux

Change directory in a shell script

How do u change ur directory using a shell script?? (12 Replies)
Discussion started by: laxmi
12 Replies

9. Shell Programming and Scripting

change directory using shell script

How do u change ur directory using a shell script?? (0 Replies)
Discussion started by: laxmi
0 Replies

10. Shell Programming and Scripting

change directory

hi, Iam in directory A. I run a script from there. inside the script i have a command cd B. When i come out of the script directory is A only. Even when i come out scrip i want the directory to be B How to achieve (2 Replies)
Discussion started by: mkan
2 Replies
Login or Register to Ask a Question