Syntax for a single-line Bash infinite while loop

前端 未结 13 1382
长情又很酷
长情又很酷 2020-11-29 14:18

I am having trouble coming up with the right combination of semicolons and/or braces. I\'d like to do this, but as a one-liner from the command line:

while [         


        
相关标签:
13条回答
  • 2020-11-29 15:09

    You don't even need to use do and done. For infinite loops I find it more readable to use for with curly brackets. For example:

    for ((;;)) { date ; sleep 1 ; }
    

    This works in bash and zsh. Doesn't work in sh.

    0 讨论(0)
提交回复
热议问题