我必须替换简单的xml标签
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
通过
<connector name="http" protocol="HTTP/1.1" scheme="http"
socket-binding="http"
enabled="false"/>
我如何使用sed命令实现这一目标
我尝试用简单的sed命令替换,因为我是初学者使用
sed 's/connector name="http" protocol="HTTP\/1.1" scheme="http" socket-binding="http"/connector name="http" protocol="HTTP\/1.1" scheme="http" socket-binding="http" enable="false"' abcd.xml`
但我收到了消息
command garbled: s/connector name="http" protocol="HTTP\/1.1" scheme="http" socket-binding="http"/connector name="http" protocol="HTTP\/1.1" scheme="http" socket-binding="http" enable="false"
答案 0 :(得分:1)
s/old/new/
命令缺少最终斜杠。尝试:
sed 's/connector name="http" protocol="HTTP\/1.1" scheme="http" socket-binding="http"/connector name="http" protocol="HTTP\/1.1" scheme="http" socket-binding="http" enable="false"/' abcd.xml