在Solaris创建目录的shell脚本:
#!/bin/sh
#ifmkdir
#parameter is passed as $1 but reassigned to DIRECTORY
DIRECTORY=$1
#is the string empty??
if [ "$DIRECTORY" = "" ]
then
echo "Usage: `basename $0` directory to create" >&2
exit 1
fi
if[ ! -d $DIRECTORY ]
then
echo "The directory does't exist" #14行
echo -n "Create it now? [y..n] :"
read ANS
if [ "$ANS" = "y" || "$ANS" = "Y" ]
then
echo "creating now"
#create directory and send all output to /dev/null
mkdir $DIRECTORY >/dev/null 2>&1
if [ $? != 0 ]
then
echo "Errors creating the directory $DIRECTORY" >&2
exit 1
fi
fi
fi