What it does: Packages reusable steps with names and arguments—helps keep scripts tidy and testable.
What is it? Functions let you name a block of commands and reuse it. They help keep scripts tidy.
#!/bin/bash
sum() {
local total=0
for n in "$@"; do
(( total += n ))
done
echo "$total"
}
echo "Sum is: $(sum 3 4 5)"