KSH - type ENTER to continue

Hello,

Is ther any way to run a loop which promt an echo"waiting for user to hit ENTER"
sleeps for an iterval and once user hit the ENTER key the loop exit and the script continue to the next stage?

I need this ASAP !!!

Thanks!!

How about:

echo "waiting for user to hit ENTER"
while read answer; do
  if [ -z "$answer" ]; then
    break
  fi
done

or

echo "waiting for user to hit ENTER"
answer=x
until [ -z "$answer" ]; do
  read answer
done

Another try

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

Thank for your reply.
this is not what is need...
I need an echo "hit enter" running every 3 seconds till user hit enter key.

Are you sure you want this? A computer impatiently pushing the user to provide an answer may be perceived as irritating..

Yes i am sure.
I need it for a specific client and i am aware of it beeing irritating.
still the requierment is the same:
I need an echo "hit enter" running every 3 seconds till user hit enter key.

OK, try this:

answer=x
while : ; do
   echo "waiting for user to hit ENTER"
   sleep 3
done &
pid=$!
until [ -z "$answer" ]; do
  read answer
done
kill $pid
1 Like

THANK!!!!!

read has -t option too, u can try that also...

while [ 1 ]
do
read -p "waiting for user to hit ENTER" -t 3 var
echo $var
done

give the appropriate condition to come out of loop...

Can we have something like below?

echo 'You have selected option $varChoice. Press ENTER to continue or press ESC to choose again...'

Means, the code for ESC and re-enter the choice.