Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
让我们这样分配:
a=7 b=29 [[ $a < $b ]] && echo dasf
它不起作用!
然而,当
a=1
b 和命令相同,效果很好。
这很时髦!有人可以解释一下吗?
您是在词法上比较变量,而不是在数字上。
尝试
[[ $a -lt $b ]] && echo smaller
或者
(( $a < $b )) && echo smaller