取代旧的链接网址将新链接的网址与SED [英] replace old-link-url to new-link-url with sed
本文介绍了取代旧的链接网址将新链接的网址与SED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在写在bash脚本将取代旧的链接网址将新链接网址
我的问题是,SED无法取代,因为斜杠的URL。如果我把只是一些文字工作原理。
我的code
SED -e S /$ old_link/$ new_link/ G wget2.html> playlist.txt
解决方案
SED
支持的任何的字符作为分隔符,所以如果你的模式试图取代包含 /
,使用不同的分隔符。最常用的是#
和 |
SED的|美孚|酒吧| G'输入
SED的##foo的酒吧#G'输入
I'm writing a script in bash that would replace old-link-url to new-link-url my problem is that sed can't replace the url because of the slashes. If i put just some text it works.
my code
sed -e s/"$old_link"/"$new_link"/g wget2.html > playlist.txt
解决方案
sed
supports any character as separator, so if the pattern you are trying to replace contains /
, use a different separator. Most commonly used are #
and |
sed 's|foo|bar|g' input
sed 's#foo#bar#g' input
这篇关于取代旧的链接网址将新链接的网址与SED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文