Syntax for a single-line Bash infinite while loop

前端 未结 13 1398
长情又很酷
长情又很酷 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 14:48

    I like to use the semicolons only for the WHILE statement, and the && operator to make the loop do more than one thing...

    So I always do it like this

    while true ; do echo Launching Spaceship into orbit && sleep 5s && /usr/bin/launch-mechanism && echo Launching in T-5 && sleep 1s && echo T-4 && sleep 1s && echo T-3 && sleep 1s && echo T-2 && sleep 1s && echo T-1 && sleep 1s && echo liftoff ; done
    

提交回复
热议问题