您的位置:首页 > 其它

自动判断某一文件的类型

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: