The below example shows how to use case statement in bash scripting.
#!/bin/bash value=123 #We can give the expected value to this variable. case ${value} in 2) echo "2";; apple) echo "apple";; a|b|c) echo "Input value is $val";; [Yy][Ee][Ss]) echo "Yes";; [5-9]*) echo "A value between 5 and 9 inclusive" *) echo "Some other value";; esac
Comments
Post a Comment