lee@sq.sq.com (Liam R. E. Quin) (11/11/89)
John Gayman <john@wa3wbu.uucp> wrote: >> I'm trying to use "cd" in a bourne shell script >> [...] I end up in the same directory I started from. danl@midget.towson.edu writes: >you could execute it as: > $ . script_name If you are using the System V shell (or SunOS /bin/sh these days), you could also define a shell function: start(){ date who cd /users } Put this -- and any others you invent -- in a standard place, such as /usr/local/lib/sh-functions, make it executable with chmod +x, and add if [ -x /usr/local/lib/sh-functions ] then . /usr/local/lib/sh-functions fi into either /etc/profile (at the end) or the users' own .profiles. Then they don't need to type the dot. This question seems to come up a lot, but this particular (somewhat pragmatic) solution seems not to be suggested often, so I have posted it here. Lee -- Liam R. Quin, Unixsys (UK) Ltd [note: not an employee of "sq" - a visitor!] lee@sq.com (Whilst visiting Canada from England) lee@anduk.co.uk (Upon my return to England at Christmas)