运维网's Archiver
论坛
›
Shell/Powershell
› shell基础之利用shell检测目录是否存在,不存在提示让用户创建目录
sunyke
发表于 2018-8-27 13:25:47
shell基础之利用shell检测目录是否存在,不存在提示让用户创建目录
#!/bin/bash
if [ -e $1 ]
then
echo "目录存在"
else
{
echo "目录不存在,是否创建1是2否"
read -p "请输入1或者2:" mulu
if [ $mulu -eq 1 ]
then
mkdir $1
elif [ $mulu -eq 2 ]
then
exit 0
fi
}
fi
页:
[1]
查看完整版本:
shell基础之利用shell检测目录是否存在,不存在提示让用户创建目录