Reputation: 1054
WARNING! Getting pretty basic here guys...
I have a rather elaborate shell script that I wish to create, but am haveing difficulty with the most basic of commands so am struggling to get going.
I want to create a .sh file that I can simply run using BASH - If I place just CD in the file and run in BASH nothing happens, whereas running CD from the terminal obv. gets me home.
Could someone shed some light on this please... I am running OSX
thanks
Upvotes: 0
Views: 343
Reputation: 27567
When you run a script you spawn a new sub-shell, your cd
works in that and then you exit back to your orginal shell and your old present work directory - just as thought the cd
never happened. If you want to short cut cd
s use a alias
or a function. Something like:
go_dev() {
cd /my/long/path/to/dev/env/
}
or
alias go_dev='cd /my/long/path/to/dev/env/'
Upvotes: 2