[PLUG] Shell script problem
netvaibhav at gmail.com
Sun Aug 5 18:21:34 IST 2007
On 8/5/07, Vaibhav Kulkarni <netvaibhav at gmail.com> wrote:
> Try sourcing your script.
Oh, I forgot to mention the reason why it doesn't work in your case.
When you run your script, a sub-shell is created, which cd's into that
particular directory. When the script is done, the sub-shell exits and
you are returned to the 'main' shell, which is still in the original
directory. Now when you add /bin/sh in the script, it spawns a
sub-sub-shell, which inherits the current directory from the
sub-shell, which is your newly created date folder.
Sourcing a scripts runs the commands in the current shell, instead of
spawning a sub-shell.
More information about the Plug-mail