Computing.Net > Forums > Unix > Changing directory

Changing directory

Reply to Message Icon

Original Message
Name: ravi.kumar
Date: April 27, 2005 at 05:19:03 Pacific
Subject: Changing directory
OS: Unix
CPU/Ram: 256MB
Comment:

Hi,
I have a directory A in my home dir, I need a script to change to dir A, after executing the script I shouldn't be in my home dir (i.e pwd should show /home dir/A) how can I do this

Hello I am working extensively on SCM and Unix


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: April 27, 2005 at 07:21:14 Pacific
Subject: Changing directory
Reply: (edit)

Hi:

Executing a shell script spawns a child shell. In order for your directory changes for to remain in effect once the child terminates, you must "source" the script:

. myscript.ss

For sh/ksh/bash scripts, from the command-line, that is a period, a space, and the script name.

Regards,

Nails


Report Offensive Follow Up For Removal

Response Number 2
Name: Luke Chi
Date: April 27, 2005 at 08:41:55 Pacific
Subject: Changing directory
Reply: (edit)

I created many alias in my .profile file, like:

alias _o='cd $ORACLE_HOME; pwd'
alias _j='cd $J2EE_HOME; pwd'
alias _p='cd $APACHE_HOME; pwd'
alias _b='cd $B2B_HOME; pwd'
...

then, for example
$ _o
$ /u01/oracle/product/10.1.0/Edge/j2ee/home


Luke Chi


Report Offensive Follow Up For Removal

Response Number 3
Name: ravi.kumar
Date: April 27, 2005 at 22:17:34 Pacific
Subject: Changing directory
Reply: (edit)

Hi,

Thanx, it worked

Hello I am working extensively on SCM and Unix


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Changing directory

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge