• Arun Kumar

Shell Script for Multiple Choice Questions

Linux shell script allows you to present a multiple choice question and gets the user’s answer, and reports back whether the answer is right, wrong, or not one of the choices. Here we will user case to match the answer which we accept using the read command.

vi multi_choice_question.sh
# !/bin/bash

echo Shell script is
echo a\) an Operating System
echo b\) a media player
echo c\) a command-line interpreter
echo d\) all of the above
read answer
case $answer in
a) echo Wrong - the answer is c ;;
b) echo Wrong - the answer is c ;;
d) echo Wrong - the answer is c ;;
c) echo Right ;;
*) echo Not one of the choices ;;

Here is the sample output of the above script

More way to use this case command

  • You can use the case command to evaluate the argument.

  • You can also use it to return the output according to the user inputs.


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