hands-on lab

Working with Case Statements in Your Shell Scripts

Up to 30m
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.


Case statements can offer an easy-to-read alternative to traditional conditional statements that utilize if/elif/else. Similar to conditional statements, case statements allow you to determine flow within your shell scripts. One common use case is comparing the same variable against potential values that perform specific actions.

In this lab, you will utilize case statements in a Linux shell script. The commands used in this lab have been covered in the Case Statements in Shell Scripts course. References to the specific lessons of the course will be provided throughout the lab steps.

The expected outputs for each lab step are provided as comments in the lab script file.

Learning Objectives

Upon completion of this lab, you will be able to:

  • Vary the flow of your shell script with case statements

Intended Audience

  • Those beginning to work with Linux
  • Those looking to gain experience with basic shell scripting
  • Software Engineers
  • DevOps Engineers


You should be familiar with the following Linux scripting features before attempting this lab:

  • Case Statements
  • Vim, Nano, or Emacs

Refer to the following courses to fulfill the prerequisite:

About the author

Jun Fritz, opens in a new tab
Cloud Labs Developer
Learning paths

Jun is a Cloud Labs Developer with previous experience as a Software Engineer and Cloud Developer. He holds the AWS Certified Solutions Architect and DevOps Engineer Professional certifications. He also holds the AWS Certified Solutions Architect, Developer, and SysOps Administrator Associate certifications. 

Jun is focused on giving back to the growing cloud community by sharing his knowledge and experience with students and creating engaging content. 

Covered topics

Lab steps

Accessing the Amazon Linux 2 Terminal
Modifying Your Lab Shell Script
Determining Flow with Case Statements