test 表达式 =[ 表达式 ]
测试文件属性
-b file 如果文件存在且为块设备(Block special),值为真
-c file 如果文件存在,且为字符设备(Character special),值为真
-r file 如果文件存在,且只为可读,值为真
-w file 如果文件存在,,且可写入,值为真
-x file 如果文件存在,且可执行,值为真
-s file 如果文件存在,且长度大于0,值为真
-d file 如果文件存在,且为目录,值为真
-f file 如果文件存在,且普通文件,值为真
-e file 如果文件存在,值为真
测试数值
等于 n1 -eq n2
不等于 n1 -ne n2
大于 n1 -gt n2
小于 n1 -ge n2
大于等于 n1 -ge n2
小于等于 n1 -le n2
测试字符串
-z s1 字符串长度为0
-n s1 长度不为0
s1 =s2 字符s1与s2相等
s1!=s2 s1与s2不相等
s1 字符不为空
测试逻辑运算符
-a 与(and)
-o 或(or)
! 非(not)