323
Comment:
|
870
portability
|
Deletions are marked like this. | Additions are marked like this. |
Line 4: | Line 4: |
No, but you can use these: | Use the following to wait until the user presses enter: |
Line 6: | Line 6: |
echo press enter to continue; read | # Bash read -p "Press [enter] to continue..." # Bourne echo "Press [enter] to continue..." read junk |
Line 8: | Line 13: |
Or use the following to wait until the user presses any key to continue: |
|
Line 9: | Line 16: |
echo press any key to continue; read -n 1 | # Bash read -sn 1 -p "Press any key to continue..." |
Line 11: | Line 19: |
If you want to put a timeout on that, use the `-t` option to `read`: |
|
Line 12: | Line 22: |
read -p 'press enter to continue' | # Bash echo "WARNING: You are about to do something stupid." echo -n "Press a key within 5 seconds to cancel." if ! read -sn 1 -t 5 then something_stupid fi |
Line 14: | Line 29: |
If you just want to pause for a while, regardless of the user's input, use `sleep`: {{{ echo "The script is tired. Please wait a minute." sleep 60 }}} |
Is there a "PAUSE" command in bash like there is in MSDOS batch scripts? To prompt the user to press any key to continue?
Use the following to wait until the user presses enter:
# Bash read -p "Press [enter] to continue..." # Bourne echo "Press [enter] to continue..." read junk
Or use the following to wait until the user presses any key to continue:
# Bash read -sn 1 -p "Press any key to continue..."
If you want to put a timeout on that, use the -t option to read:
# Bash echo "WARNING: You are about to do something stupid." echo -n "Press a key within 5 seconds to cancel." if ! read -sn 1 -t 5 then something_stupid fi
If you just want to pause for a while, regardless of the user's input, use sleep:
echo "The script is tired. Please wait a minute." sleep 60