create directory

Hi,

I want to create directory using shell scripts,

my directory will be created with todays date and the scripts will run everyday many times but directory will be created only once and that too when scripts run first time.

if directory exist then
do nothing
else
mkdir RIO_`date +%d-%b-%Y`
fi

Can you please guide how to check if the same directory exist and then come out from the if and go to next statement in the scripts.

Hi,

NEWDIR=RIO_`date +%d-%b-%Y`
if [ -d $NEWDIR ]
then
    echo "exist"
else
 echo "Not exist"
fi

Use the -p option of the mkdir command, check the man page of your mkdir version.

[ ! -d $(date "+%d-%b-%Y") ] || echo "dir does not exist"

Hi -p option is file but it give error message when there is a directory exist, in that case script will terminate which i don't want

How did you use the command? Something like this should work:

NEWDIR=RIO_`date +%d-%b-%Y`
mkdir -p "$NEWDIR"