我有一个 HTML 创建脚本,在其中我试图:
1.) 使用 SED 将 RelatedLinksBlock 的所有实例替换为多行 DOS 变量
2.) 查找与 DOS 变量匹配的字符串并使用 SED 将其移除或删除
几个小时后,我无法让任何一个 SED 命令工作,需要一些帮助。
代码:
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
set nl=^& echo.
set fullHTMLpath=http://this.com
set FileTitle=Computer TEST
set keyfile=test.html
set rempath=REMthisOUT
set "delpath=^<li^> - ^<a href="%fullHTMLpath%" title="%FileTitle%"^>%FileTitle%^</a^>^</li^>"
set "path1=^<li^> - ^<a href="http://that.com/computers-and-operating-systems/asus-computer-support.html" title="ASUS Computer Support"^>ASUS Computer Support^</a^>^</li^>"
set "path2=^<li^> - ^<a href="http://that.com/computers-and-operating-systems/asus-laptop-support.html" title="ASUS Laptop Support"^>ASUS Laptop Support^</a^>^</li^>"
set "path3=^<li^> - ^<a href="http://that.com/computers-and-operating-systems/asus-support.html" title="ASUS Support"^>ASUS Support^</a^>^</li^>"
set alllinks=%path1%%nl%%path2%%nl%%path3%
sed -i "s/RelatedLinksBlock/%alllinks%/g" "%keyfile%"
sed -i "s/%delpath%/%rempath%/g" "%keyfile%"
谢谢