Re: bash ?
Jijo Jose A wrote:
> I had a bash script and it have the line
>
> #--------- script begins
> cd /usr/share/doc
> pwd
> exit 0
> #---------- ends
>
> when i run the code within HOME
> it outputs
>
> /usr/share/doc
>
> but after i exited from the script ,current directory remains the HOME.
> i need to cd through the script .what can i solve this ?
Your script is executed in a subshell, so of course your main shell isn't
affected by the change of directory.
You could simply source the script instead of executing it in a subshell,
but I think a better solution would be to make this an alias.
Craig
Reply to:
- Follow-Ups:
- Re: bash ?
- From: "Karsten M. Self" <kmself@ix.netcom.com>
- References:
- bash ?
- From: Jijo Jose A <jijojose@sancharnet.in>