我猜它代表的不是基於輸出,但我在哪裏可以找到有關此語法的文檔?在這個bash while循環的布爾表達式中,-lt是什麼意思?
#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 10 ]; do
echo The counter is $COUNTER
let COUNTER=COUNTER+1
done
我猜它代表的不是基於輸出,但我在哪裏可以找到有關此語法的文檔?在這個bash while循環的布爾表達式中,-lt是什麼意思?
#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 10 ]; do
echo The counter is $COUNTER
let COUNTER=COUNTER+1
done
-lt
小於(嚴格)。
您正在查找的手冊頁是man test
。
n1 -lt n2
True如果整數n1是代數大於整數N 2以下;否則,是錯誤的。
n1 -le n2
如果整數n1代數小於或等於整數n2,則爲真;否則,是錯誤的。
是的,是一個循環迭代
COUNTER=0 // set zero to variable COUNTER
while [ $COUNTER -lt 10 ]; // check while $COUNTER less than 10 (-lt)
do // * if the check is true, do this
echo The counter is $COUNTER // print the string
let COUNTER=COUNTER+1 // reassign COUNTER = current value - 1
done // end of *
文檔: - http://www.gnu.org/software/bash/manual/bashref.html#Bash-Conditional-Expressions
'在{} 0..9櫃檯;不要回聲 「計數器爲$計數器」; done'是恕我直言,更安全,更清晰。 – potong