mac执行sed命令报错
$ touch testing.txt
$ echo "this is mkyong.com" > testing.txt
$ cat testing.txt
this is mkyong.com
$ sed -i 's/mkyong/google/g' testing.txt
sed: 1: "testing.txt": undefined label 'esting.txt'
This
sed -i 's/mkyong/google/g' testing.txt
command is working properly in Linux, but hits “undefined label” error message on Mac OS X.
这里添加需要的参数
$ sed -i '.bak' 's/mkyong/google/g' testing.txt
$ ls -ls
8 -rw-r--r-- 1 mkyong staff 19 Aug 2 14:22 testing.txt
8 -rw-r--r-- 1 mkyong staff 19 Aug 2 14:21 testing.txt.bak
$ cat testing.txt
this is google.com
$ cat testing.txt.bak
this is mkyong.com