When writing Bash scripts it is common to check a string against a variable and then do something based on what was specified.
Consider the following script. It checks the first argument that a user specifies and does different things depending on what was given.
This demonstrates albeit with no functionality a simple task that can repeat a known shape back to a user or if the shape is unknown show an error message.
Everythingaposs fine and dandy in this and it all works as expected. But look at how many lines that took. See how you have to handle every single option that a user passes through an elif statement.
Now imaging this program has even more options say 20. With the current approach you are going to be writing an if statement with 20 elif sections inside it.
Yeah youaposll probably be able to read it for the most part. But itaposs clunky takes up too much space and most importantly there is a better alternative.
News Link: https://linuxhandbook.com/bash-case-statement/.