using cd command in a file
Simon Grouchy Babes Chapman
chapmns at motcid.UUCP
Thu May 23 18:35:03 AEST 1991
In article <1991May20.155136.25162 at ux1.cso.uiuc.edu> ceblair at ux1.cso.uiuc.edu (Charles Blair) writes:
>
> I would like to get to a directory /me/A/B/C/D by just typing j. I tried
>creating a file j with cd /me/etc in it, then chmod +x j. It didn't work.
>Thanks in advance. I'm sure I'm overlooking something well-known.
Surely executing this shell script will spawn a new process, and for the
process itself, the directory will alter, but the effects of the change
will not be exported to the parent process; the shell you run the script
from. I don't think that it is possible to do this using a script in the
way you mean, but two alternatives exist that I know of :
For c-shell: use an alias :
alias j "cd /me/A/B/C/D"
For Bourne Shell: use a function :
j() { cd /me/A/B/C/D ; }
Both of these do NOT spawn another process to do their stuff.
If anyone else can show us both how to do an "export cwd > parent.proc."
I'd be interested.
Cheers,
thimon
---------------------------------------------------+---------------------------
Just 'cos you're not paranoid, doesn't mean | Simon Chapman
they're not out to get you. | U.K. Motorola Cid.
| ...uunet!motcid!chapmns
---------------------------------------------------+---------------------------
More information about the Comp.unix.questions
mailing list