我需要编写一个执行以下操作的bash脚本:
cp index.html index2.html
src="videos/
内的某些字符(index2.html
)替换为新字符,即src="content://com.company.app/videos/
src="videos/
替换为src="content://com.company.app/videos/
index2.html
如你所见,我可以做第一步。但是,我需要帮助做第2步。我应该在bash脚本中写什么?
答案 0 :(得分:1)
sed -ri 's~(src=")(videos\/)~\1content\://com.company.app/\2~' index2.html
使用sed,您可以使用-r启用正则表达式,并使用-i启用index2.html的更改。然后我们用括号括起来分割src =“并用视频做同样的事情\然后我们将它们称为\ 1和\ 2添加附加文本.s表示sed替换模式,所以s~text in file~text to改为〜