自动判断某一文件的类型
2012-08-09 15:47
246 查看
自动判断某一文件的类型
目的:自动判断系统中某一文件的属性。
#!/bin/bash
read -p "please input one file:" FILE
read -p "please input one dir:" DIR
if [ -e /$DIR/$FILE ];then
STRING=`/bin/ls -l -d $DIR/$FILE`RST
FIRSTCHAR=`echo ${STRING:0:1}`
case $FIRSTCHAR in
-)
echo "the $DIR/$FILE is file";;
d)
echo "the $DIR/$FILE is dir";;
l)
echo "the $DIR/$FILE is link file";;
*)
exit
esac
else
echo " the $DIR/$FILE IS NOT EXIST:"
fi
本文出自 “心灵规划” 博客,请务必保留此出处http://haoxiaoyang.blog.51cto.com/4449963/959422
目的:自动判断系统中某一文件的属性。
#!/bin/bash
read -p "please input one file:" FILE
read -p "please input one dir:" DIR
if [ -e /$DIR/$FILE ];then
STRING=`/bin/ls -l -d $DIR/$FILE`RST
FIRSTCHAR=`echo ${STRING:0:1}`
case $FIRSTCHAR in
-)
echo "the $DIR/$FILE is file";;
d)
echo "the $DIR/$FILE is dir";;
l)
echo "the $DIR/$FILE is link file";;
*)
exit
esac
else
echo " the $DIR/$FILE IS NOT EXIST:"
fi
本文出自 “心灵规划” 博客,请务必保留此出处http://haoxiaoyang.blog.51cto.com/4449963/959422
相关文章推荐
- asp.net 下载文件时根据MIME类型自动判断保存文件的扩展名
- asp.net 下载文件时根据MIME类型自动判断保存文件的扩展名
- Java遍历文件夹&判断是否存在某一类型的文件
- 下载文件时根据MIME类型自动判断保存文件的扩展名
- php 网页播放器用来播放在线视频的代码(自动判断并选择视频文件类型)
- 下载文件时根据MIME类型自动判断保存文件的扩展名巧解
- 下载文件时根据MIME类型自动判断保存文件的扩展名(转)
- 艾伟_转载:下载文件时根据MIME类型自动判断保存文件的扩展名
- 判断浏览器类型屏幕分辨率自动调用不同CSS文件
- php 网页播放器用来播放在线视频的代码(自动判断并选择视频文件类型)
- 根据文件头数据判断文件类型
- 判断文件的类型
- linux 删除当前目录下的某一类型文件
- android读取中文txt,lrc的乱码(自动判断文档类型并转码)
- 判断文件类型
- JavaScript客户端判断文件类型及大小
- C/C++中判断某一文件或目录是否存在
- 如何在编译时刻判断两个类型是否可以自动转换?——《Modern C++ Design》读书笔记(1)
- php 读取文件头部两个字节 判断文件的实际类型