What is the Linux equivalent to DOS pause?

前端 未结 9 560
猫巷女王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:55

    read -n1 is not portable. A portable way to do the same might be:

    (   trap "stty $(stty -g;stty -icanon)" EXIT
        LC_ALL=C dd bs=1 count=1 >/dev/null 2>&1
    )   

    Besides using read, for just a press ENTER to continue prompt you could do:

    sed -n q 

提交回复
热议问题