页次: 1
shell(linux 条件测试)
示例
[root@ippbs ~]# test "this is test" [root@ippbs ~]# echo $? 0 # 字符串不为空返回的都是真, 0 表示真 [root@ippbs ~]# test -n "this is test" [root@ippbs ~]# echo $? 0 # 这个也是真的 [root@ippbs ~]# test -z "this is test" [root@ippbs ~]# echo $? 1 # -z表示测试是否是空的。 这个是不是空的返回1 [root@ippbs ~]# test -n "" [root@ippbs ~]# echo $? 1 # 如果是空的返回0 [root@ippbs ~]# [root@ippbs ~]# test "abc" = "abcd" [root@ippbs ~]# echo $? 1 # 测试是否相等 [root@ippbs ~]# test "abc" != "abc" [root@ippbs ~]# echo $? 1 # 测试不相等
ipbbs.net
离线
页次: 1