Last active
June 30, 2016 03:03
-
-
Save akhy/6b067d288694d6660ab07209675dd40f to your computer and use it in GitHub Desktop.
Shell Cheatsheet
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
# looping over array | |
for i in "${arrayName[@]}"; do | |
# do whatever on $i | |
done | |
# Switch-case | |
case ${ENV} in | |
"development") | |
;; | |
"staging") | |
;; | |
"production") | |
;; | |
*) | |
;; | |
esac | |
# ENV validation | |
case ${ENV} in | |
"development") ;; | |
"staging") ;; | |
"production") ;; | |
*) | |
echo "ENV should be one of: [development staging production]" | |
exit 1 | |
;; | |
esac | |
# strip prefix from filenames | |
for f in prefix-*; do mv "$f" "${f#prefix-}"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment