我有一个 GNU makefile
,其中的配方行之一是:
sed -i 's|<span class="math">$$\(.*\)$$</span>|<span style="font-size:100%">'"$$(curl -d "type=tex&q=\1" http://localhost:16000/)"'</span>|g' $(NAME).a4.xhtml
这个想法是替换<span class="math">$$\(.*\)$$</span>
经过<span style="font-size:100%">..SVG..</span>
where..SVG..
是执行 shell 命令返回的字符串curl -d "type=tex&q=\1" http://localhost:16000/
, where\1
应该是先前记住的模式\(.*\)
。
问题:模式检测和 shell 执行都工作正常。但是,\1
不会被先前记住的模式所取代。
PS:如果更喜欢sed
与-r
选项一起使用,里面的匹配makefile
如下:
sed -i -r 's@<span class="math">\$$(.*)\$$</span>@..@..' $(NAME).a4.xhtml