当前位置: 技术问答>linux和unix
创建文件的问题
来源: 互联网 发布时间:2016-03-01
本文导语: #!/usr/bin/ksh . ~/.profile #ifmkdir DIRECTORY=$1 if [ "$DIRECTORY" = "" ] then echo "Usage:`basename $0` directory to create" >&2 exit 1 fi if [ -d $DIRECTORY ] then :# no thing 空命令 else echo " this directory d...
#!/usr/bin/ksh
. ~/.profile
#ifmkdir
DIRECTORY=$1
if [ "$DIRECTORY" = "" ]
then
echo "Usage:`basename $0` directory to create" >&2
exit 1
fi
if [ -d $DIRECTORY ]
then :# no thing 空命令
else
echo " this directory does exits "
echo -n "Create it now ?[y..n]:"
read ans
if [ "$ans" = "y" ] || [ "$ans" = "Y" ]
then
echo "create it now ";
mkdir $DIRECTORY > /dev/null 2>$1
if [ $? != 0 ]
then
echo "Errors creating the directory $DIRECTORY" >$2
exit 1
fi
else :
fi
fi
这里mkdir总是报错,它没有创建目录而是创建了一个文件
我是刚开始学的
哪位大哥大姐来帮帮我
. ~/.profile
#ifmkdir
DIRECTORY=$1
if [ "$DIRECTORY" = "" ]
then
echo "Usage:`basename $0` directory to create" >&2
exit 1
fi
if [ -d $DIRECTORY ]
then :# no thing 空命令
else
echo " this directory does exits "
echo -n "Create it now ?[y..n]:"
read ans
if [ "$ans" = "y" ] || [ "$ans" = "Y" ]
then
echo "create it now ";
mkdir $DIRECTORY > /dev/null 2>$1
if [ $? != 0 ]
then
echo "Errors creating the directory $DIRECTORY" >$2
exit 1
fi
else :
fi
fi
这里mkdir总是报错,它没有创建目录而是创建了一个文件
我是刚开始学的
哪位大哥大姐来帮帮我
|
mkdir $DIRECTORY > /dev/null 2> $1
是不是应该这样
mkdir $DIRECTORY > /dev/null 2> &1
重定向出错输出不用$,而是用$
是不是应该这样
mkdir $DIRECTORY > /dev/null 2> &1
重定向出错输出不用$,而是用$