• Arun Kumar

Shell Script Simple Quiz

Linux shell script allows the user to check for the answer until the correct answer given by the user. We are using the While loop to achieve it. The while loop enables you to execute a set of commands repeatedly until some condition occurs.

vi simple_quiz.sh
# !/bin/bash

echo What is the National Animal of INDIA
read ans
while test $ans != tiger
echo No, that\'s not it. Try again.
read ans
echo That is correct.

Here is the sample output of the above script

More ways to use this while loop.

  • You can use while loop will print welcome 5 times on screen: x=1; while [ $x -le 5 ]; do echo "Welcome $x times" $(( x++ )); done

  • You can also use it while as infinite loops: while :; do echo 'Press <CTRL+C> to exit.'; sleep 1; done


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