如何在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
相關文章
相關標籤/搜索