SED空格/换行符匹配-Linux

SED空格/换行符匹配-Linux,linux,bash,sed,Linux,Bash,Sed,基本上,我想做的是使用sedlinux版本在HTML文件中进行更改。当我执行这段代码时,我得到一个未知的命令错误,因为sed不能分辨什么是空白或换行符 sed 's|<a href="es/map-button.html"> <div class="map-button">|<div id="confirmation" onclick="confirmation()" class="map-button"> &l

基本上,我想做的是使用sedlinux版本在HTML文件中进行更改。当我执行这段代码时,我得到一个未知的命令错误,因为sed不能分辨什么是空白或换行符

sed 's|<a href="es/map-button.html">
            <div class="map-button">|<div id="confirmation" onclick="confirmation()" class="map-button">
            <script type="text/javascript">
<!--
              function confirmation() {
                var answer = confirm("Access map? (uses internet)")
                  if (answer){
                    window.location = "google.maps.com";;
                  }
                  else{
                    //alert("Returning to current content")
                  }
              }
//-->
            </script>|g' *.html

我的分隔符是您在这里看到的|。

使用sed的change命令

sed '/<a href="es\/map-button\.html">/{
    N
    /<div class="map-button">/c\
<div id="confirmation" onclick="confirmation()" class="map-button">\
<script type="text/javascript">\
<!--\
function confirmation() {\
    var answer = confirm("Access map? (uses internet)")\
    if (answer){\
        window.location = "google.maps.com";;\
    }\
    else{\
        //alert("Returning to current content")\
    }\
`}\
//-->\
</script>
}' *.html

删除模式空间。使用0或1地址或在2地址范围的末尾,文本被写入标准输出

问题是什么?您面临的问题是什么?抱歉,应该详细说明。基本上,当我执行那段代码时,我得到一个未知的命令错误,因为sed无法分辨明显的空格或换行符。奇怪的是,我得到的错误是未终止的“s”命令,这是因为s命令的参数不能包含文字换行符。你不能像这样使用sed。sed一次只读取一行到模式空间。
/address/c\
text