shell脚本之判断文件类型

  1. 原码如下:
#!/bin/bash
#check that the files exists.
addr=/home/hadoop/test.txt
if [ -d  $addr ]
then echo $addr is a directory
elif [ -e  $addr ]
then echo $addr is a file
fi