【问题标题】:remove specific set of lines with bash script使用 bash 脚本删除特定的行集
【发布时间】:2019-04-05 00:17:58
【问题描述】:

您好,我来自很多线程来完成这项任务,但都不适合我。我有大量看起来像这样的文件:

{

    ... 

    frontAndBack
    {
        type            empty;
        inGroups        1 ( empty );
        nFaces          2428620;
        startFace       2264091;
    }

    frontAndBack
    {
        type            empty;
    }

}

我想删除包含这部分的行:

    frontAndBack
    {
        type            empty;
    }

我试试这个:

sed -zi.bak 's/"    frontAndBack\n    {\n        type            empty;\n    }"//g' boundary

但是没有用。有什么帮助吗?

【问题讨论】:

  • perl -0777 -p -e 's/\s*frontAndBack\s*{\s*type\s*empty;\s*}//g' input
  • @WilliamPursell 谢谢,把它作为答案你给你投票

标签: bash text replace


【解决方案1】:

sed 中的多行匹配是……痛苦的。但是perl 擅长这种事情:

perl -0777 -p -e 's/\s*frontAndBack\s*{\s*type\s*empty;\s*}//g' input-path 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-16
    • 1970-01-01
    • 2019-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多