[CentOS] Scripting a directory change on CentOS

James B. Byrne byrnejb at harte-lyne.ca
Mon Jul 30 16:49:08 UTC 2007


This is probably a FAQ item but despite searching extensively with google
I am unable to find an answerer to this question.  Perhaps I am using the
wrong words. In any case, at the risk of inducing some mirth at my
ignorance, how can one script a cd command so that that the user remains
in that directory when the script exits?

I have to work with a long path to a project working directory and I would
like to have a simple script called "current" which would produce the same
effect as issuing this from the shell:

cd ./very/long/path/to/obscurely/titled/project/directory

I cannot seem to find anything that directly addresses this, other than to
point out that shell scripts run in their own copy of the shell
interpreter and so anything done to the PWD therein is local to the
duration of the script.  I could create a logical link from my home
directory I suppose, but I desire a scripted solution.

I really do not wish to program a utility to do this and I cannot believe
that many people have not already addressed this desire with a straight
forward answer. So if any of you have a simple to implement solution then
could you share your answer with me?

As I am a digest subscriber in addition to your answer to the list the
favour of a direct reply is requested

Sincerely,

-- 
***          E-Mail is NOT a SECURE channel          ***
James B. Byrne                mailto:ByrneJB at Harte-Lyne.ca
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3




More information about the CentOS mailing list