天天看点

测试一个目录或者文件

im test.sh

#!/bin/bash

if [ -e $1 ];then

if [ -f $1 ];then

echo "$1 is a file"

elif [ -d $1 ];then

echo "$1 is a directory"

else

echo "$1 is unknow"

fi

echo "You fool,please gei me a correct file"

本文转自 张玉坡 51CTO博客,原文链接:http://blog.51cto.com/fighter/462704