use Linux Friends might be more familiar with the command，It can quickly and text documents in batches to operate in the script，For example a row or alternatively change the specific content ......
macOS Naturally have this command，But one thing is not quite the same，If you execute and -i ，So probably you will get a strange error and: 1: “…”: invalid command code 。
After the query that，This command is a little change in macOS，and It allows you to set a backup file when replacing to avoid data loss - This option is optional in Linux，But in macOS is mandatory，So，In the macOS and -i It will be one more argument，If you did not give，The overall parameter leading to a less，Then an error。
~/ sed -i 's/1/1/g' a
sed: 1: "a": command a expects \ followed by text
- “invalid command code .” error from sed after running find and sed on Mavericks
- and: 1: “…”: invalid command code on Mac OS
Reproduced Please keep the source and description link：https://www.logcg.com/archives/3142.html