In this article, we will see how to use "case" to execute a statement or block of statements depend on a case.
CASE in bash work similar to CASE in other programming languages. It executes statement or statements of code with predefined conditions.
Lets look to CASE syntax in bash shell.
case $1 in
apache)
echo "apache log...";;
jboss/wildfly)
echo "jboss/wildfly log..."
esac
Lets see it in bash shell scripting example.
As above output indicates, we are taking an argument from bash script call. If argument contains "apache" it executes a block corresponding to that.