I'm confused about the semicolon used with find's -exec action. Why do commands usually end with ; or ';' instead of an unescaped semicolon? What happens if I use a plain ;, or leave the terminator out entirely? The find manual says the semicolon may need to be protected from shell expansion, but I'm not sure what "shell expansion" means or why it matters here.
2 Answers
The shell parses and expands your command line before launching find. Expansion can include wildcard or glob expansion, such as turning `*.txt` into a list of matching filenames, along with other substitutions defined by the shell. Characters such as `;`, `*`, `$`, backticks, and parentheses can have special meanings, so quote or escape them when you need them passed literally to another program. For this particular case, `;` and `';'` both protect the semicolon from the shell; find then receives it and uses it to recognize the end of the `-exec` command.
A plain semicolon is handled by the shell before find ever runs. In shell syntax, ; separates commands, so something like `find . -exec echo {} ;` is parsed as if the find command ends before find receives the semicolon. Escaping it as `;`, or quoting it as `';'`, prevents the shell from treating it as command syntax and passes the literal semicolon to find as the end marker for `-exec`.

You can’t simply leave it out because find needs a terminator to know where the command given to `-exec` ends. The alternative form `+` also terminates `-exec`, while grouping multiple paths into fewer command invocations.