Last active
January 9, 2018 20:38
-
-
Save robballou/b40673598ea6ce56963fbf9d43a33879 to your computer and use it in GitHub Desktop.
Bash examples for my own memory's sake...
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
#!/bin/bash | |
# check number of arguments, output a message to STDERR | |
if [[ "$#" -eq "0" ]]; then | |
2>&1 echo "Usage: $0 FILE" | |
exit 1 | |
fi | |
# check if an argument equals a string | |
if [[ "$1" = "dev" ]]; then | |
# ... | |
fi | |
# one line if... | |
if [[ "$1" = "dev" ]]; then echo "If"; else echo "Else"; fi | |
# arrays and looping over them | |
repos=(example1 example2) | |
for repo in "${repos[@]}"; do | |
echo $repo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment