A Bash function groups commands under a name. Calling the function runs its body with its own positional arguments.

Program

Play the script to watch the call pass Ada into the function body.

functions.sh
#!/usr/bin/env bash

greet() {
  local name="$1"
  echo "Hello, $name"
}

greet "Ada"
function A function names a reusable group of shell commands.
local `local` keeps a variable scoped to the current function call.