How to cd into a directory and stay there
0
Q:
How to cd into a directory and stay there
How to cd into a directory and stay there ?


Please help me with modifying the script, or some other
different way of accomplishing the objective.



Software/Hardware used:
Linux
ASKED: Oct 24 2009  7:49 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
How to cd into a directory and stay there ?

I use a circuit design CAD tool such that I have a frequent need to cd into a directory for my circuit design. For example, if my circuit design is called ckt1, then I want to cd into
/abc/def/ghi/lmn/ck1/opq/rst/uvw

I like to make a shell script, let say: cdc
Where the content of the cdc is:

cd /abc/def/ghi/lmn/$1/opq/rst/uvw

So at the Unix/Linux command line, when I type: cdc ckt2
It will get me to the directory within the script execution, the problem is that I want
to remain at that directory, at the parent level when I type in the cdc ckt2 command.

Please help me with modifying the script, or some other different way of accomplishing the objective.
Last Answered: Oct 24 2009  7:52 PM GMT by Whattheheckisthis   20 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Sds9985   365 pts.  |   Oct 26 2009  5:37PM GMT

You need to “source” the script, so that it’s effective on the parent shell.

Instead of:

myscript

or

sh myscript

use

. myscript

 

Petkoa   1005 pts.  |   Oct 27 2009  11:14AM GMT

Or define a function in your profile ( ~/.bash_profile in bash ):

function cdc () {
cd /abc/def/ghi/lmn/$1/opq/rst/uvw
}

Good luck,

Petko A.

 

How to cd into a directory and stay there | Linux Affinity   0 pts.  |   Oct 31 2009  2:23PM GMT

[...] post: How to cd into a directory and stay there Posted in: How To’s ADD [...]

 
0