【问题标题】:How to grep for a long html string with quotes and carriage returns如何grep带有引号和回车符的长html字符串
【发布时间】:2021-10-19 01:15:23
【问题描述】:

我需要递归查找所有包含以下 HTML 的文件:

<html id="blx-5fb3c619e82a2863d6567c52-000000001" class="blx-5fb3c619e82a2863d6567c52">
    <head>
    <meta charset="utf-8">
    <meta name="google" value="notranslate">

我正在尝试以下方法但没有成功:

grep --include=\*.html -FRnw "/path-to-dir" -e '<html id="blx-5fb3c619e82a2863d6567c52-000000001" class="blx-5fb3c619e82a2863d6567c52">\n    <head>\n    <meta charset="utf-8">\n    <meta name="google" value="notranslate">'

我做错了什么?

【问题讨论】:

  • grep 一次处理文件一行,不能进行多行匹配。

标签: linux grep


【解决方案1】:

使用 GNU grep。删除-F-n"/path-to-dir"并添加-Poz

【讨论】:

    猜你喜欢
    • 2018-09-10
    • 1970-01-01
    • 1970-01-01
    • 2011-09-23
    • 1970-01-01
    • 1970-01-01
    • 2021-07-29
    • 1970-01-01
    • 2019-12-28
    相关资源
    最近更新 更多