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。
1 2 3 |
~/ sed -i 's/1/1/g' a sed: 1: "a": command a expects \ followed by text ~/ sed -i '.bak' 's/1/1/g' a |
Extended reading
- “invalid command code .” error from sed after running find and sed on Mavericks
- and: 1: “…”: invalid command code on Mac OS
Original article written by LogStudio:R0uter's Blog » and: 1: “…”: invalid command code
Reproduced Please keep the source and description link:https://www.logcg.com/archives/3142.html
This command is not familiar with
Very good article like
awesome!
Thank you :)