ost of you may be aware of old good DOS/2000/XP pause command. It is used to display the prompt while suspending the processing of a batch script. It is used within a computer batch file and allows the computer to pause the currently running batch file until the user presses any key. Let us see how to pause our bash based shell script for a given number of times in seconds/minutes/hours before continuing to next operation/command running on a Linux or Unix-like systems.


bash pause command under Linux / UNIX / macOS

There is no pause command under Linux/UNIX bash shell. You can easily use the read command with the -p option to display pause along with a message.

Bash add pause prompt using sleep and read command in shell scripts under Linux and Unix

Bash add pause prompt in a shell script with bash pause command

For example:

read -p "Press [Enter] key to start backup..."
read -p "Press any key to resume ..."
## Bash add pause prompt for 5 seconds ##
read -t 5 -p "I am going to wait for 5 seconds only ..."

#bash #pause #linux #unix

Bash add pause in shell script with bash pause command
30.45 GEEK