On Mon, Jul 07, 2003 at 12:07:19PM +1000, Simon Bryan wrote:

> I also need a simple bash script that creates a directory if it doesn't exist
> 
> if directory/path does not exist
>     then mkdir directory/path
> endif

    [ -a $dir ] || mkdir -p $dir

-a tests that nothing called `$dir' exists (file, directory, symlink,
etc).  mkdir -p creates a directory and and intermediate directories
needed.  So, if `a' exists but `b' doesn't, `mkdir a/b/c' will fail but
`mkdir -p a/b/c' will create both `b' and `c'.


Cheers,

John
-- 
whois [EMAIL PROTECTED]
GPG key id: 0xD59C360F
http://kirriwa.net/john/
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to