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.
我看到这样的代码:
while :; do #commands done
是不是一样
while : do #commands done
这只是一个无限循环吗?
:是一个内置的外壳Null command。您可以help :在终端中输入:
:
Null command
help :
:: : Null command. No effect; the command does nothing. Exit Status: Always succeeds.
它看起来像/bin/true。
/bin/true
是的,这只是一个无限循环。您通常会发现循环内的代码在满足某些条件时while调用以退出循环。break
while
break