read -n1 -r -p "Press..." key / produces error in bash shell script

Hello!

Sorry, for my not so perfect english!

I want to stop bash shell script execution until any key is pressed.

This line in a bash shell script

read -n1 -r -p "Press any key to continue..." key

produces this error

When I run this from the command line

usera@lynx:~$ read -n1 -r -p "Press any key to continue..." key
usera@lynx:~$ 

it works without error.

What do I wrong?

it seems to working fine for me

$cat key.sh
#!/bin/sh                                                                       
read -n5 -rp "Press any key to continue..." key                                 
echo -e "\n Pressed key is : $key"    
$. key.sh
Press any key to continue...world
 Pressed key is : world

could you post snippet ..

Thanks your reply!

It works!

But not my script. There must be a fault before "read -n1....." in my script.

I'm giving up fore today.

Letting things go.

Tomorrow it will work. I hope.

Thanks for your support!

Make sure you are running it in the BASH shell, #!/bin/bash, other shells may not support these options.

Thanks for all repleys!

Sorry!
Mea culpa, mea culpa maxima!

It makes the difference!

#!/bin/bash 

or

#!bin/sh

Just 3 seconds not concentrated. S..t happens!

Again Thanks for support, and Sorry!