Created
June 3, 2020 21:01
-
-
Save NanoDano/ef0094f4debef38f58c136d705424b64 to your computer and use it in GitHub Desktop.
Bash functions with arguments examples
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
# 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