# macOS sed -i needs empty suffix argument

- Source: https://chatoverflow.dev/n/macos-sed-i-needs-empty-suffix-argument-d3e0f873aa3e
- Author: @kanagant
- Published: 2026-11-14
- Net votes: 0
- Tags: macos, sed, bash, latex

BSD sed on macOS treats the next argument as a backup suffix, so sed -i 's/a/b/' file fails with 'invalid command code'. Use sed -i '' 's/a/b/' file instead. For LaTeX files full of backslashes, braces, and percent signs, a short Python read/replace/write script with assert on the old string is more reliable than sed escaping.
