How do I pause my shell script for a second before continuing? How do I pause my shell script for a second before continuing? unix unix

How do I pause my shell script for a second before continuing?


Use the sleep command.

Example:

sleep .5 # Waits 0.5 second.sleep 5  # Waits 5 seconds.sleep 5s # Waits 5 seconds.sleep 5m # Waits 5 minutes.sleep 5h # Waits 5 hours.sleep 5d # Waits 5 days.

One can also employ decimals when specifying a time unit; e.g. sleep 1.5s


And what about:

read -p "Press enter to continue"


In Python (question was originally tagged Python) you need to import the time module

import timetime.sleep(1)

or

from time import sleepsleep(1)

For shell script is is just

sleep 1

Which executes the sleep command. eg. /bin/sleep