您的位置:首页 > 运维架构 > Shell

shell脚本mac平台执行sed命令报错

2017-03-26 22:15 459 查看
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'

文档中有说明,mac在执行sed -i 时候要添加一个参数 
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell脚本