如何在Shell脚本中声明和使用布尔变量? - How can I declare and use Boolean variables in a shell script?

问题:

I tried to declare a Boolean variable in a shell script using the following syntax: 我尝试使用如下语法在Shell脚本中声明布尔变量: shell

variable=$false

variable=$true

Is this correct? 这个对吗? Also, if I wanted to update that variable would I use the same syntax? 另外,若是我想更新该变量,我会使用相同的语法吗? Finally, is the following syntax for using Boolean variables as expressions correct? 最后,使用布尔变量做为表达式的如下语法正确吗? express

if [ $variable ]

if [ !$variable ]

解决方案:

参考一: https://stackoom.com/question/CONS/如何在Shell脚本中声明和使用布尔变量
参考二: https://oldbug.net/q/CONS/How-can-I-declare-and-use-Boolean-variables-in-a-shell-script
相关文章
相关标签/搜索