Student Reviews
( 5 Of 5 )
1 review
Video of Master Linux Shell Scripting: Learn Case statement in Bash Scripting course by Infinite Linux channel, video No. 14 free certified online
A case statement is a way to control the flow of a shell script by allowing you to specify multiple branches of code to be executed based on a single variable. It is similar to the switch statement in other programming languages.
case variable in
pattern1)
commands1;;
pattern2)
commands2;;
.
esac
The variable is the value that the case statement will use to determine which branch of code to execute. The pattern1, pattern2, etc. are the different values that the variable can take on, and the corresponding commands1, commands2, etc. are the commands that will be executed if the variable matches the corresponding pattern.