linux shell程序,如何输入一个文件名判断它是文件夹还是文件?
推荐于2017-10-06
展开全部
//是目录不是文件夹
#! /bin/bash
# filename:FileType.sh
read -p "Please input the filename :" filename
fpath=$filename
if [ -d $fpath ];
then
echo "$fpath is a direstory.";
elif [ -e $fpath ];
then
echo "$fpath is a file.";
else
echo "$fpath is NOT a file or direstory.";
fi
#! /bin/bash
# filename:FileType.sh
read -p "Please input the filename :" filename
fpath=$filename
if [ -d $fpath ];
then
echo "$fpath is a direstory.";
elif [ -e $fpath ];
then
echo "$fpath is a file.";
else
echo "$fpath is NOT a file or direstory.";
fi
追问
你能给解释一下吗?
追答
下次解释,现在没空
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询