To check whether a directory is exist and if it is not, create it

Hi,

I want to write a shell script to check whether a directory (say A) is existing in a given location and if it is not, create it.

[ -d /some/directory ] || mkdir /some/directory

"-d" checks to see if a directory exists, the "||" means if the prior test fails do the next action, in this case, make the directory.

try to grep it... if it's not existed, the grep will return null.. if this is true make the directory..

#! /bin/ksh

var=$( ls -1 \Yourpath | grep "A" )

if [[ "$var" -eq " " ]] ; then

mkdir A

done

Hi!
This may depend on other stuff of course... but generally if You want a directory, just create it, and if You don't want the error message use the -p option.

Otherwise, Gee-Money has the correct method.

/Lakris