Zest.

Bash: Variables and arguments

A short, tested Bash example for variables and arguments. Copy it and adjust the names and paths for your project.

Bash
name="world"
echo "Hello, $name"

echo "$1" "$2"                 # first and second argument
echo "$@"                      # all arguments
echo "${1:-default}"           # default when unset
echo "$#"                      # number of arguments

Find it in Zest

Search for “bash variables and arguments” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Bash examples

All Bash examples