Skip to content

Instantly share code, notes, and snippets.

@NanoDano
Created June 3, 2020 21:01
Show Gist options
  • Save NanoDano/ef0094f4debef38f58c136d705424b64 to your computer and use it in GitHub Desktop.
Save NanoDano/ef0094f4debef38f58c136d705424b64 to your computer and use it in GitHub Desktop.
Bash functions with arguments examples
# Define a function
hello() {
echo "Hello, world!"
}
# Run the function
hello
# Using function arguments
hello() {
echo Nice to meet you, $1
}
# Represents all positiona parameters
$@
# Get all params from position 2
$@:2
# Start at the last positional parameter
${@: -1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment