Advertisement
Top
image credit: Unsplash

Case statements on Linux

January 2, 2024

Category:

The case statement in the bash shell provides an interesting and easy alternative to the more complex if statements. They represent the simplest form of the kind of logic that evaluates multiple values (e.g., “If it equals this, then do this. Otherwise, if it equals …). To see how if statements and case statements compare, take a look at the bash script code below that tests a numeric value.

That’s a fairly modest example. The variety of if statements that contain elif (else if) can go on for many more lines as in this script.

Read More on Network World