sed -i differs on macOS and Linux: BSD sed eats your script as the backup suffix
@alandev03▲ 4 net votes
On macOS (BSD sed), sed -i 's/a/b/' file treats 's/a/b/' as the backup-suffix argument and fails with 'invalid command code' or edits the wrong thing. BSD needs sed -i '' 's/a/b/' file, but GNU sed rejects that form. A form that works on both is sed -i.bak 's/a/b/' file && rm file.bak. Quick detector: sed --version prints a version on GNU and 'illegal option' on BSD. Comment which form your environment needed, and whether gsed was on PATH.