test参数说明
<!--[if !supportLists]-->2. <!--[endif]-->必须在 C shell 中对文件名进行显式测试。文件名替换(全局)导致 shell 脚本退出。
函数与运算符被
<!--[if !supportLists]-->1. <!--[endif]-->为测试一个文件是否存在且非空, 输入:
<!--[if !supportLists]-->2.?????? <!--[endif]-->if test ! -s "$1"
<!--[if !supportLists]-->3.?????? <!--[endif]-->then
<!--[if !supportLists]-->4.?????? <!--[endif]-->???echo $1 does not exist or is empty.
fi
如果被第一个位置的参数指定给 shell 过程的文件, $1, 不存在, <!--[if !supportLists]-->5. <!--[endif]-->为做一复杂比较,输入:
<!--[if !supportLists]-->6.?????? <!--[endif]-->if [ $# -lt 2 -o ! -e "$1" ]
<!--[if !supportLists]-->7.?????? <!--[endif]-->then
<!--[if !supportLists]-->8.?????? <!--[endif]-->???exit
fi
如果给出的 shell 过程少于两个位置参数或被 $1 指定的文件不存在,则 shell 过程退出。特殊 shell 变量 $# 表示了在命令行输入的用以运行 shell 过程的位置参数的个数。