Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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


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

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:


echo 'Are you sure? Press Ctrl-C to abort.'
sleep 3
share|improve this question

2 Answers 2

up vote 6 down vote accepted

something along the lines of

echo -n "prompt"  #'-n' means do not add \n to end of string
read              # No arg means dump next line of input
share|improve this answer
In Bash, this can be shortened to read -p "prompt". More details on shell built-ins can be retrieved with the help command, e.g. help read. –  Lekensteyn Feb 27 '12 at 17:32
@Lekensteyn - That's without a trailing newline though. –  Matt H Mar 15 '12 at 18:36
@MattH Just like echo -n and printf. If you press Enter, you will get a newline. –  Lekensteyn Mar 15 '12 at 19:54
that does not work for ubuntu 12.04 - read requires argumenst –  ses May 14 '14 at 20:09
@ses On 12.04.4 using bash there is no requirement that read have an argument. Using sh (which often invokes bash in sh compatible mode) read requires an argument. If you start your script with #!/bin/sh you will see the latter behavior –  Huckle May 15 '14 at 1:33
echo "press enter to continue"
read unusedVariable
echo "running these 3 lines in .sh file, this echo will never be seen, unless you have a really slow computer"

place these 3 lines in a .sh file and run it

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.