sed多行替换为Apaches';改装

sed多行替换为Apaches';改装,apache,sed,mod,Apache,Sed,Mod,我想调整某些文件的apache输出,以便: <template> <p>... something in there ...</p> <template>... something in there ...</template> ... more stuff ... </template> <script> ... my script ... export default something

我想调整某些文件的apache输出,以便:

<template>
  <p>... something in there ...</p>
  <template>... something in there ...</template>
  ... more stuff ...
</template>

<script>
  ... my script ...
  export default something;
</script>
但我遇到的巨大问题是,当涉及到中间部分时。因此,我想删除最后一个关闭
标记(注意可能有嵌套的
标记!)到第一个(也是唯一的)
标记的任何内容,包括标记本身。问题是,在这两个标记之间可能存在任意数量的换行符和/或空白。现在我有了多行替换,这应该可以通过
mode_sed
实现,但是我发现的所有示例在apache上下文中都不起作用,到目前为止我似乎无法运行任何东西

非常感谢您的帮助

const template = `
  <p>... something in there ...</p>
  <template>... something in there ...</template>
  ... more stuff ...
`

... my script ...
export default something;
OutputSed "s/<template>/const template = `/g"
OutputSed "s/<\/script>/ /g"