Bash Script

Bash Cases Statement

The case construct in bash shell allows us to test strings against patterns that can contain wild card characters. Bash case statement is the simplest form of the bash if else then condition statement. The simple example for this is if you are expecting different inputs from a user and want to execute specific command sets on the choice used.     case $variable in pattern1 ) statements ;; pattern2 ) statements ;; * ) statements ;; … esac   We can see the common use of the case statement in the init scripts of the services which has the options like start, stop, restart and status.  ...

Read More