Exercise: Case Statement

Put to practice what we’ve learned about the case statement.

We'll cover the following

Exercise

Consider the following script. Rewrite it with the case statement.

#!/bin/bash
if [[ "$1" = "Alice" ]]
then
    echo "Hello Alice"
elif [[ "$1" = "Bob" ]]
then
    echo "Hello Bob"
else 
    echo "Hello John Doe"
fi

Click on the Run button after making any changes in the file.

Get hands-on with 1200+ tech skills courses.