shell脚本-判断是否是目录,文件,其他文件
作者:蓝眼泪
实验环境:centos7.9 ,vim15
#!/bin/bash
read -t 30 -p "please input a filename:" filename
if [ -z $filename ]
then
echo "the filename is error or not exist"
exit 101
elif [ ! -e $filename ]
then
echo "the value is null"
exit 102
elif [ -d $filename ]
then
echo "this is a directory"
elif [ -f $filename ]
then
echo "this is a normal filename"
else
echo "this is an other filename"
fi