Situation

When Use sed -i Get invalid command code A Error

$ sed -i "" 's/foo/bar/g' some.conf
sed: 1: "some.conf": invalid command code A

Cause

After man sed In macOS

 -i extension
             Edit files in-place similarly to -I, but treat each file independently from other files.  In particular, line numbers in each file start at
             1, the “$” address matches the last line of the current file, and address ranges are limited to the current file.  (See Sed Addresses.) The
             net result is as though each file were edited by a separate sed instance.

sed Command In macOS Will Backup Automatically, So You Need Give Some SUFFIX If You Want Backup Or You Can Use Zero-Length Like "" To Skip Backup.

Solution

sed -i "" 's/foo/bar/g' some.conf