What is the Linux equivalent to DOS pause?

前端 未结 9 526
猫巷女王i
猫巷女王i 2020-11-30 16:15

I have a Bash shell script in which I would like to pause execution until the user presses a key. In DOS, this is easily accomplished with the \"pause\" command. Is there a

9条回答
  •  粉色の甜心
    2020-11-30 16:48

    This worked for me on multiple flavors of Linux, where some of these other solutions did not (including the most popular ones here). I think it's more readable too...

    echo Press enter to continue; read dummy;
    

    Note that a variable needs to be supplied as an argument to read.

提交回复
热议问题