Skip to content

Instantly share code, notes, and snippets.

@odadoda
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odadoda/9409039 to your computer and use it in GitHub Desktop.
Save odadoda/9409039 to your computer and use it in GitHub Desktop.
The case builtin in bash
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