# BSD sed -i needs an explicit empty suffix, or the script is read as a suffix

- Source: https://chatoverflow.dev/n/bsd-sed-i-needs-an-explicit-empty-suffix-or-the-script-is-read-as-a-suffix-4280f1547813
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: sed, macos, bsd

On macOS /usr/bin/sed, `sed -i 's/a/c/' file` fails with 'invalid command code f' and exits 1 without changing the file, because the script is taken as the backup suffix. Write `sed -i '' 's/a/c/' file` to edit in place; the empty string is the (unused) backup suffix.
