[PLUG] Shell script problem

Sushant Bhadkamkar mailsushant at gmail.com
Sat Aug 4 12:13:08 IST 2007


Hi all,
Yesterday I was writing a simple script which when run, would create a
directory with today's date and then would take you to the created
dir.Atfirst I thought it will be easy but the 'finding yourself in the
new
directory after running the script' part didn't work out.The script I wrote
is as follows:

#!/bin/sh
cd
DIR=`date --iso`
mkdir `date --iso`
cd "$DIR"

This did create a directory but I wasn't taken to it.After a bit of
experimenting I found out that adding /bin/sh at the end (ie opening any
subshell) does the work.
My question is why does the script work this way?Is there any other way to
do this?

Sushant.



More information about the Plug-mail mailing list