自動判斷某一文件的類型

                             自動判斷某一文件的類型

目的:自動判斷系統中某一文件的屬性。

#!/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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章