脚本——判断文件类型

#!/bin/bash
echo "检测文件类型"
read -ep "请输入要检测的路径" file
if [ ! -e $file ]
then
  echo "文件不存在,请检查输入是否正确"
elif [ -L $file ]
then
  echo "链接文件"
elif [ -d $file ]
then
  echo "目录"
elif [ -f $file ]
then
  echo "普通文件"
else
  echo "其他文件类型"
fi

原文地址:https://www.cnblogs.com/hyydeali/p/12838597.html