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

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

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

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


        
5条回答
  •  被撕碎了的回忆
    2020-12-10 20:14

    You could "recurse" using the following line:

    exec bash "$0" "$@"
    

    Since $0 is the path to the current script, this line starts the script without creating a new process, meaning you don't need to worry about too many restarts overflowing the process table on your machine.

提交回复
热议问题