Last active
August 29, 2015 13:57
-
-
Save odadoda/9409039 to your computer and use it in GitHub Desktop.
The case builtin in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case $VAL in | |
( 1 ) echo "The val is 1" ; echo "Echoing out some more text" ;; | |
( 2 ) echo "The val is 2" ;; | |
( * ) echo "The value is not 1 or 2" ;; | |
esac | |
# There is a shorter version to case aswell | |
case $OS in | |
ubuntu ) echo "Running ubuntu" ;; | |
centos ) echo "Running centos" ;; | |
easc | |
# if the values in "OS" are string you dont really need quotationmarks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment