Score:0

How to Pause the Shell?

us flag

I have a shell script that ends with exit 0 and want to pause it before executing the command.

Cyrus avatar
cn flag
Replace `exit 0` with `read; exit 0`.
Score:0
sa flag

Insert this code in your shell script before the line in your shell script that executes the command.

echo "Press any key to continue."
while [ true ] ; do
read -t 10 -n 1  
echo ""
if [ $? = 0 ] ; then
exit;
else
echo "Waiting for a keypress..."
fi
done

The code waits 10 seconds for a the user press any key and then prompts the user again to press any key to continue. If three seconds is too long to wait then change the 10 in the line that says read -t 10 -n 1 to a smaller number.

source: revised from Bash wait for keypress

Score:0
tr flag

To pause for 3 seconds,

sleep 3
bac0n avatar
cn flag
I think OP is looking for `read -p "Press [Enter] ..."`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.