Skip to content

Instantly share code, notes, and snippets.

@akhy
Last active June 30, 2016 03:03
Show Gist options
  • Save akhy/6b067d288694d6660ab07209675dd40f to your computer and use it in GitHub Desktop.
Save akhy/6b067d288694d6660ab07209675dd40f to your computer and use it in GitHub Desktop.
Shell Cheatsheet
# 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