[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: using cd is shell script



On Sun, Aug 26, 2001 at 05:26:36PM -0700, bob parker wrote:
> Hi all,
> being a lazy typist i have writen a little script that
> goes like this:
> 
> #! /bin/bash
> #     go-xxx where xxx is the last dir in along chain
> 
> cd /some long dir chain/xxx
> 
> 
> My question is, how can i make the change persist
> after the script is done

You can't by simply executing it. Your environment is passed
up to child processes but not down to parent ones.

You need to "source" it..that is run it in-line in the shell.
In "bash" you use a "." to do this, in csh/tcsh you use "source".

Cliff



Reply to: