Switch (Case) Statment in Bash The case statement is useful and processes faster than an else-if ladder. Instead of checking all if-else conditions, the case statement directly select the block to execute based on an input. Create the first program using the case statement in a shell script. The program takes input from the user and executes statements based on the input value.
read -p "Enter your choice [yes/no]:" choice
case $choice in
echo "Thank you"
echo "Your type: Yes"
echo "You type: No"
echo "Sorry, invalid input"
Save the above script in case1.sh and execute the script on bash shell. chmod +x case1.sh ./case1.sh Enter your choice [yes/no]:yes Thank you Your type: Yes…Read More