• Arun Kumar

Shell script to ask for favourite colour with a time limit

Linux bash script allows you to accept user inputs within the time limit and read what user types on the screen. This is achieved by Linux read with -t command within the script. In the below script, we will be asking users their favorite color and the user has to enter within 5 seconds and prompt the user with the input they have typed on the screen else exit from the script.

vi favourite_color.sh
# !/bin/bash

read -t 5 -p "Type your favorite color: " color
echo $color

Here is the sample output of the above script.

More ways to use a time limit Input Bash Script

  • We can set a time limit for the password section, if the user delay entering the password then the user will exit from the login.

  • You use a time limit with a quiz where the user has to answer the question within time.


Recent Posts

See All

Oracle 19c Installation on Linux

Oracle 19c adds more features to Oracle database and this article demonstrates Oracle 19c installation on Linux 7. We will be using Oracle Linux 7 and Oracle Database 19.3 softwares for this activity.

Basic Linux Commands

This article describes basic Linux commands that you must know as a system or database administrator. Below commands in Linux help you manage any Linux server fast and smoothly. Linux Command List Che

Linux Firewall with iptables and firewalld

In this article will be covering details regarding iptables and firewalld which helps in Linux firewall management. We will also be looking at how to enable specific ports (1521 for Oracle) inside ipt