Use case for Complicated Conditional Statements in Bash

Share this video with your friends

Send Tweet

Lots of if and if else statements are hard to read and tough to maintain in any language, and bash is no exception. In this lesson, we’ll learn how to use case, bash’s construct for a switch statement. In bash, case actually does pattern matching, which gives some great flexibility. We’ll write a script that will uncompress a variety of different archive file types (like .tar or .zip), based on their file extension.