Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!casbah.acns.nwu.edu!ftpbox!motsrd!motcid!chapmns From: chapmns@motcid.UUCP (Simon ( Grouchy Babes ) Chapman) Newsgroups: comp.unix.questions Subject: Re: using cd command in a file Message-ID: <7204@maize.UUCP> Date: 23 May 91 08:35:03 GMT References: <1991May20.155136.25162@ux1.cso.uiuc.edu> Organization: Motorola (UK) Ltd., Cellular Infrastructure Div., Swindon, England Lines: 33 In article <1991May20.155136.25162@ux1.cso.uiuc.edu> ceblair@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 ---------------------------------------------------+---------------------------