sed: sed command a expects followed by text
来源:互联网 发布:淘宝帐号三星 编辑:程序博客网 时间:2024/06/05 11:26
在mac osx lion中sed来进行文件内容的替换操作,使用命令为:
sed -i 's/oldstring/newstring/g' full-path-file
执行后提示出错,错误信息为:“sed: 1: command a expects \ followed by text”,但是相同的命令拿到centos下确能执行成功。 使用man查看命令的参数详细说明,两个系统下对参数“i”的要求不一样。
mac osx中为:
-i extension Edit files in-place, saving backups with the specified extension. If a zero-length extension is given, no backup will be saved. It is not recommended to give a zero-length extension when in-place editing files, as you risk corruption or partial content in situations where disk space is exhausted, etc.
centos中为:
-i[SUFFIX], --in-place[=SUFFIX] edit files in place (makes backup if extension supplied)
参数“i”的用途是直接在文件中进行替换。为防止误操作带来灾难性的后果,sed在替换前可以自动对文件进行备份,前提是需要提供一个后缀名。从上面对参数“i”的详细说明中可以看到,mac osx下是强制要求备份的(当然也可以使用空字符串来取消备份),但centos下是可选的。
如果不需要备份文件,mac osx下可以使用如下命令完成替换操作:
sed -i '' 's/oldstring/newstring/g' full-path-file
0 0
- sed: sed command a expects followed by text
- 【FAQ】Mac下,执行sed命令报错:“command c expects \ followed by text”,怎么办?
- sed command
- sed -- command function
- Sed command usage
- Linux Shell Sed command
- sed command
- Linux sed command
- Linux: sed command
- linux sed command record
- Linux Command -- sed
- sed
- Sed
- SED
- sed
- sed
- sed
- sed
- 整数划分
- Linux下查看文件和文件夹大小
- javaEE开发模式的演变
- 【Android】Android布局中实现圆角边框
- spring中bean,factorybean与beanfactory
- sed: sed command a expects followed by text
- 千与千寻无脸男的真面目 无脸男为什么对千寻好
- android 6.0下载更新之后安装APK
- javascript轻量级模板引擎juicer使用指南
- vagrant
- 一头扎进设计模式-状态模式
- Vmware创建虚拟机centos遇到问题
- swift中array数组的使用
- Android-多级列表-popupWindow