如何使用sed删除html中的html标记、脚本和空行?

如何使用sed删除html中的html标记、脚本和空行?,html,linux,bash,sed,Html,Linux,Bash,Sed,我试过一些方法,但我做不到 sed -e "s/<!---* *<\(.*\)> *-->/<\1>/" test.html sed-e“s//”test.html 我在这里找到了,但我不知道如何继续。我尝试按照脚本删除html/tags并输出剩下的内容 输入文件:(test.txt) 这回答了你的问题吗?让perl与您在一起--`perl-0777-pe's///sg'test.htmlIf您想删除空行,那么perl-0777-pe's///sg;s/\

我试过一些方法,但我做不到

sed -e "s/<!---* *<\(.*\)> *-->/<\1>/" test.html
sed-e“s//”test.html

我在这里找到了,但我不知道如何继续。

我尝试按照脚本删除html/tags输出剩下的内容

输入文件:(test.txt)


这回答了你的问题吗?让perl与您在一起--`perl-0777-pe's///sg'test.htmlIf您想删除空行,那么
perl-0777-pe's///sg;s/\s+\n+/\n/g'test.html
我只能使用sed:/
<!DOCTYPE html>

  <head>

    <script>
      function myFunction() {
        document.getElementById("demo").innerHTML = "Paragraph changed.";
      }
    </script>

    <title>Sample page</title>

    <style>
      html { color: #837456; }
      body { background: white; }
    </style>

  </head>

  <body>
    <p>Hello here!</p>
  </body>

</html>
cat test.txt | sed 's/$/©/' | tr -d '\n' | sed 's/<script.*<\/script>//g' | sed 's/<[^>]*>//g' | sed 's/©/\n/g' | sed '/^ *$/d' | sed 's/^ *//'
Sample page
html { color: #837456; }
body { background: white; }
Hello here!