Header Ads

Shell Scripting - Example of a Simple Case Operation - 06

This is a Simple usage Example of a 'Switch Case' operation in Shell Scripting. 

This program prints the read value from user and prints the value from switch case. 

Program Code:

#!/bin/bash
#Simple Case operation in Shell!

echo " Enter a Number (1 to 9) : "
read x
case $x in
 1) echo "Value of x is One.";;
 2) echo "Value of x is Two.";;
 3) echo "Value of x is Three.";;
 4) echo "Value of x is Four.";;
 5) echo "Value of x is Five.";;
 6) echo "Value of x is Six.";;
 7) echo "Value of x is Seven.";;
 8) echo "Value of x is Eight.";;
 9) echo "Value of x is Nine.";;
 *) echo "Invalid Entry!.";;
esac

Program Output:

No comments