![](/img/trans.png)
[英]How to replace external CSS file link in html with the content of the CSS file using shell script?
[英]How to replace a html comments using shell script
我试图使用shell脚本取消注释html文件中的一行,但我无法为此编写一个sed命令。
我有一条线
<!--<url="/">-->
我需要使用shell脚本取消注释这一行
<url="/"/>
sed -i -e "s|'<!--<url="/"/>-->'|<url="/">|g" myFile.html
知道怎么替换这个评论吗?
像这样?
sed -i 's|<!--<url="/">-->|<url="/">|g' myFile.html
最好使用单引号,因为它会阻止对包括双引号在内的所有内容的解释。
你需要在/
character之前转义(添加反斜杠)。
其次,两个关键参数都应该用/
分隔,而不是用|
分隔 。
使用以下行:
sed -i 's/<!--<url="\/">-->/<url="\/">/g' myFile.html
使用: sed -re 's/(<!--)|(-->)//g'
例如: echo '<HTML><!--<url="/">--> <BODY>Test</BODY></HTML>' | sed -re 's/(<!--)|(-->)//g'
echo '<HTML><!--<url="/">--> <BODY>Test</BODY></HTML>' | sed -re 's/(<!--)|(-->)//g'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.