判断文件类型
#!/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
shell脚本之判断文件类型
原创
©著作权归作者所有:来自51CTO博客作者一程的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java 根据HttpEntity 中contenttype获取文件类型
java 根据HttpEntity 中contenttype获取文件类型
apache HTTP Apache -
shell 脚本判断文件类型实例
简单脚本自己做个练习
职场 休闲 shell脚本 文件类型判断 -
Linux shell脚本 判断用户输入的文件类型
用if语句编写了一个在Linux操作系统下判断用户输入文件类型的脚本
Linux 脚本 shell