shell變量測試
[root@localhost ~]# unset y
#刪除變量y
[root@localhost ~]# x=${y-2}
#進行測試
[root@localhost ~]# echo $x
2
#因為變量y不存在,所以x=new
你都刪除y了,那y肯定不存在了啊,還測試?
[root@localhost ~]# unset y
#刪除變量y
[root@localhost ~]# x=${y-2}
#進行測試
[root@localhost ~]# echo $x
2
#因為變量y不存在,所以x=new
你都刪除y了,那y肯定不存在了啊,還測試?
2019-05-29
舉報
2019-05-29
不存在也是測試中的一種情況,y不存在,y為空,y設置了數值,都是可以測試出來的。