Wednesday, May 1, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 29568  / 3 Years ago, mon, june 21, 2021, 9:25:00

I need a pause on a shell script to show a warning before continuing.
For instance, on DOS it goes like this:



doit.bat:



[...]
echo 'Are you sure? Press Ctrl-C to abort, enter to continue.'
pause
[...]


How can I do this on bash?
For the moment a sleep command seems to do the trick and is simple enough but is not exactly the idea:



doit.sh



[...]
echo 'Are you sure? Press Ctrl-C to abort.'
sleep 3
[...]

More From » bash

 Answers
0

something along the lines of



echo -n "prompt"  #'-n' means do not add 
to end of string
read # No arg means dump next line of input

[#40128] Tuesday, June 22, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tionverflow

Total Points: 500
Total Questions: 115
Total Answers: 120

Location: Northern Ireland
Member since Mon, Nov 14, 2022
1 Year ago
;