As scripts grow, the same block of commands shows up in several places and becomes hard to change. Functions give that block a name so you write it once and call it with arguments. Use them for repeated steps like logging, checking a URL or deploying to one host. Bash functions return only an exit status, so print data and capture it with $( ), and mark their variables local.