How to cd into a directory and stay there

Tags:
Linux desktop environment
Linux desktops
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: October 24, 2009  7:49 PM
UPDATED: October 27, 2009  11:14 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Sds9985
    You need to "source" the script, so that it's effective on the parent shell. Instead of: myscript or sh myscript use . myscript
    400 pointsBadges:
    report
  • petkoa
    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.
    3,120 pointsBadges:
    report
  • Whattheheckisthis
    [...] post: How to cd into a directory and stay there Posted in: How To's ADD [...]
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following