On 10/14/05, David M. Cook <[EMAIL PROTECTED]> wrote:
> Is there a neater idiom for this:
>
> #!/bin/sh
>
> if test -f $1
> then
> if test ! -d $1
> then
> echo "$1 exists and is not a directory"
> exit 1
> fi
> else
> mkdir -p $1
> fi
> #########
>
> If a file exists and is not a directory, bail out, otherwise create the
> directory.
#!/bin/sh
mkdir -p $1
#######
If file does not exist, mkdir will make a directory.
If file exists and is not a directory mkdir will fail and produce the
desired error message.
If file exists and is a directory mkdir will just silently go away.
carl
--
carl lowenstein marine physical lab u.c. san diego
[EMAIL PROTECTED]
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg