带有-i选项的sed命令(就地编辑)在Ubuntu上可以正常工作,但在Mac上却不能 [英] sed command with -i option (in-place editing) works fine on Ubuntu but not Mac

查看:105
本文介绍了带有-i选项的sed命令(就地编辑)在Ubuntu上可以正常工作,但在Mac上却不能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Sed一无所知,但需要此命令(在Ubuntu上可以正常使用)在Mac OSX上运行:

I know nothing about Sed but need this command (which works fine on Ubuntu) to work on a Mac OSX:

sed -i "/ $domain .*#drupalpro/d" /etc/hosts

我得到了:

sed: 1: "/etc/hosts": extra characters at the end of h command

推荐答案

Ubuntu随GNU sed一起提供,其中-i选项的后缀是可选的. OS X随附BSD sed,其中后缀是必需的.尝试sed -i ''

Ubuntu ships with GNU sed, where the suffix for the -i option is optional. OS X ships with BSD sed, where the suffix is mandatory. Try sed -i ''

这篇关于带有-i选项的sed命令(就地编辑)在Ubuntu上可以正常工作,但在Mac上却不能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆