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
error message on Mac OS X.
这里添加需要的参数
this is mkyong.com
$ 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.txtcommand 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,为了练习sed,写了个简单的批量修改文件名的脚本,后来执行时发现系统竟然自带有一个rename命令,顺便也记下了
- shell脚本学习-8(sed命令学习)
- droid代码库之执行Shell命令或者脚本
- 40个很有用的Mac OS X Shell脚本和终端命令
- 40 个很有用的 Mac OS X Shell 脚本和终端命令
- shell脚本批量部署ssh认证+批量执行命令
- Shell脚本中滤掉"ssh -t"执行命令时返回的/r字符
- shell脚本实现每秒执行一次任务 rsync命令使用
- shell脚本执行命令 . 和sh 和 source 和 ./ 的使用以及区别
- 解决:shell脚本中,无法执行time命令,以统计某个程序执行时间
- BAT脚本如何自动执行 adb shell 以后的命令
- 在shell脚本里执行sudo 命令
- shell脚本实现每秒执行一次任务 rsync命令使用
- [转]shell脚本sed命令
- shell脚本学习-6(sed命令学习)
- shell 脚本一步一步执行命令
- 开机启动程序、脚本(开机执行命令,永久修改MAC)【仅供参考】
- 40 个实用的 Mac OS X Shell 脚本和终端命令
- shell脚本执行命令错误处理
- 40个很有用的Mac OS X Shell脚本和终端命令