Skip to content

Instantly share code, notes, and snippets.

@GabeDuarteM
Last active January 21, 2020 16:56
Show Gist options
  • Select an option

  • Save GabeDuarteM/5ece016947d97ee65cdd4cba5d5117e3 to your computer and use it in GitHub Desktop.

Select an option

Save GabeDuarteM/5ece016947d97ee65cdd4cba5d5117e3 to your computer and use it in GitHub Desktop.
basic bash stuff that I'm tired of searching whenever I need ¯\_(ツ)_/¯
# 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