Last active
January 21, 2020 16:56
-
-
Save GabeDuarteM/5ece016947d97ee65cdd4cba5d5117e3 to your computer and use it in GitHub Desktop.
basic bash stuff that I'm tired of searching whenever I need ¯\_(ツ)_/¯
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
| # return a value in a function | |
| function returnTrue() { | |
| echo true | |
| } | |
| # pass arguments to a function | |
| # | |
| # usage: | |
| # $ greeter "Gabriel" | |
| # > "Hello Gabriel" | |
| function greeter() { | |
| echo "Hello $1" | |
| } | |
| # assign function result to a variable | |
| thing="$(greeter 'Gabriel')" # Hello Gabriel | |
| # Compare strings and variables | |
| if [[ "$thing" == "false" ]]; then | |
| echo "yes" | |
| else | |
| echo "no" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment