How would I tell a bash script to start over from the top?

后端 未结 5 365
迷失自我
迷失自我 2020-12-10 19:24

For example, in the below script startover starts back from the top:

##########################################################################
         


        
5条回答
  •  天涯浪人
    2020-12-10 20:22

    Put it in a while loop. I'd also suggest you add a "sleep" so that you're not racing your machine's CPU as fast as it will go:

    while true; do
        ##########################################################################
        ## CHECK TIME
        ##########################################################################
        time=$(date +%k%M)
    
        if [[ "$time" -ge 1800 ]] && [[ "$time" -le 2200 ]]; then
            echo "Not a good time to transcode video!" && exit 0
        else
            echo "Excellent time to transcode video!" && echo "Lets get started!"
        fi
        ##########################################################################
        ## CHECK TIME
        ##########################################################################
        for i in {1..5}; do
            echo $i
            sleep 1
        done
    done
    

提交回复
热议问题