How in bash do I give the user 5 seconds to answer or assume " do not fix"

Posted on 2011-03-21
Last Modified: 2012-05-11
I have a script.  

I want to give the user 5 seconds to type if   FIX
or it will assume you do not want to fix it and it wiill just repsond with what is broke.

Question by:TIMFOX123
LVL 23

Accepted Solution

Kamaraj Subramanian earned 250 total points
ID: 35181984
check this one
echo -n "Hurry up and type something! > "
if read -t 5 response; then
    echo "Great, you made it in time!"
    echo "Sorry, you are too slow!"

Open in new window

LVL 68

Assisted Solution

woolmilkporc earned 250 total points
ID: 35182036
unset INPUT; read -t5 INPUT
if [ "$INPUT" = "FIX" ]
     echo "Correct input entered"
     # do what's needed to fix
      echo "Not fast enough!"
      # do what's needed to respond what is broke


Author Closing Comment

ID: 35184138
you make it look too easy


Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
centos commands 6 68
I NEED A "BARE" LINUX ... 9 56
Explain the command ls -1tr | head -n -10 | xargs -d '\n' rm -f -- 4 32
AWK: Pytthagoras bp script Part deux 22 33
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Recently, an awarded photographer, Selina De Maeyer (, completed a photo shoot of a beautiful event ( in An…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question