测试文件类型if...else

#!/bin/bash  
#filename=detect_file_type                                                                                      
echo "please input a file name:"
read file_name
if [ -d $file_name      ]
then
        echo "$file_name is a directory"
elif [  -f $file_name   ]
then
        echo "$file_name is a common file"
elif [  -c $file_name -o -b $file_name  ]
then
        echo "$file_name is a device file"      
else
        echo "$file_name is an unknown file"
fi
分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS