自動判斷某一文件的類型

                             自動判斷某一文件的類型bash

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

#!/bin/bash
read -p "please input one file:" FILE
read -p "please input one dir:" DIRspa

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:"
fiinput

相關文章
相關標籤/搜索