Created
January 31, 2018 12:40
-
-
Save tiagopog/1eba457730f89a4b4371e0bb149332c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
## | |
# Simple "if" statement | |
## | |
if [ "foo" == "foo" ]; then | |
echo "I'm in! (1)" | |
fi | |
# Short version | |
[ "foo" = "foo" ] && echo "I'm in! (2)" | |
# Test version | |
test "foo" = "foo" && echo "I'm in! (3)" | |
## | |
# "if/elif/else" statement | |
## | |
if [ "foo" != "foo" ]; then | |
echo "It won't enter here" | |
elif [ "foo" == "bar" ]; then | |
echo "It won't enter here" | |
else | |
echo "I'm in! (4)" | |
fi | |
## | |
# "case" statement | |
## | |
case "foobar" in | |
foo*) | |
echo "I'm in! (5)" | |
;; | |
bar) | |
echo "It won't match \"bar\"" | |
;; | |
*) | |
echo "It would enter here if nothing matches" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment