Changing Directory

David T. Sandberg dts at quad.uucp
Sun Aug 6 17:59:31 AEST 1989


In article <9730 at alice.UUCP> debra at alice.UUCP () writes:
>In article <5068 at mtuxo.att.com> jld at mtuxo.att.com (XMRJ4-J.DALTON) writes:
>>QUESTION: I have a very long path which is quite tedious to type in
>>          every time I wish to visit a certain directory.
>>	    My question: Is there a way that I can put this path in a 
>>          file, then execute a shell that will place me in that directory?
>
>You can put the name in a file, say "f", and then do a
>cd `cat f`
>You cannot put the "cd longfilename" in a shell script and execute it
>as the 'current directory' is only inherited from parent to child, not
>the other way round.
>
>If you have an ancient bourne shell you are out of luck.

?

Why are the respondents seemingly avoiding the way I usually do it
when stuck with Bourne shell?  Namely, storing the directory path
in an environment variable, ala...

$ ACE=/usr/local/ace/reports/src/more/useless/nesting; export ACE
$ cd $ACE

In fact, on machines where I only have Bourne shell to work with
(blech), I'll usually set up a number of these things in my .profile
to have ready access to my most commonly-used directories in the most
expedient fashion.  And many of the people I've worked with have done
the same thing - I'm quite surprised no one has yet suggested it here.

(You could put the 'cd' in the environment variable as well, if you
like, but I don't like to get that distant from sensible command
lines...)

I've never heard of a Bourne shell so primitive that it wouldn't
handle this correctly.  Or perhaps I've just been lucky?

-- 
                                  David Sandberg
 "bidibidibidibidi... here's      PSEUDO: dts at quad.uucp
      your flower, Buck"          ACTUAL: ..uunet!rosevax!sialis!quad!dts



More information about the Comp.unix.questions mailing list