This is a multipart blog article series where I am going to explain the concepts of shell scripting and how to write a shell script in Linux, UNIX or Mac based systems. You can also follow this tutorial blog using windows but for that you have to install a bash from.
In this article we are going to see that how can we use case statements in shell scripting.
- The case statement can be used as an alternate for if condition.
- The basic syntax of case statement is like this.
case expression in
pattern1 )
statement ;;
pattern2 )
statement ;;
esac
- Here the
)
after pattern1 and patter2 means that the case are finished. - The double semicolon
;;
after statement means that this case is true and completely executed. -
*)
this is the default case statement.
Reference code file for this article
So this was all about case statement in shell scripting, we will see an example in next article. Hope you liked it and learned something new from it.
If you have any doubt, question, quires related to this topic or just want to share something with me, than please feel free to contact me.
📱 Contact Me
Twitter
LinkedIn
Telegram
Instagram
Top comments (0)