|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Bash problems with cd
Hi,
I'm having problems with a bash script I wrote and have never been able to figure this part out. Whenever I put a cd <somedir> into a bash script it will change to that dir for the duration of the script. But, when the script is done executing I'm back in the same dir I was when I executed the script. I assume then that there is some specific command that you need to use in order to make the change stick, I just have never been able to find it. Any help would be appreciated. Thanks! |
|
#2
|
|||
|
|||
|
#!/bin/bash
dir=`pwd` <your bash script> cd $dir |
|
#3
|
|||
|
|||
|
I think he meant the opposite of that. Setting the cwd in a shell script.
You can use: Code:
. scriptfile.sh to execute the script in the running shell instead of spawning a new one. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > Linux Help > Bash problems with cd |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|