You are not logged in.
How can I make my bash script change directories so that when it exits, I will be in that directory?
Let's say I start in my home dir and run this simple one:
#!/bin/bash
echo hello world
if [ -d ~/world ]; then
cd ~/world
exit 0
else
echo error
exit 1
fi
When it exits, I am still in my home dir, not ~/world.
Offline
See Gilles' answer here: http://unix.stackexchange.com/questions … mmatically
Offline
What problem are you actually trying to solve?
Do you really need a script to be able to change the directory or are you just trying to create a shortcut that will change directory for you.
If it's the later then bash has built in support for this sort of thing.
Last edited by Slithery (2014-08-16 18:35:09)
Offline