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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
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 …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

947 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now