determine the type of shell script file

determine the type of shell script file

判断文件类型
#!/bin/bash
read -p "Please input a  filename:" file
if [ -z "$file" ];then
                echo "Error,please input a filename"
        exit 1
elif [ ! -e "$file" ];then
        echo "Your input is not  exist"
        exit 2
elif [ -d "$file" ];then
        echo "$file is a  目录文件"
elif [ -f "$file"  ];then
        echo "$file is a 普通文件"
else
        echo "你输入的文件是其他文件类型"
fi

Guess you like

Origin blog.51cto.com/11342825/2422341