【问题标题】:Regex to remove a reoccuring paragraph from text file正则表达式从文本文件中删除重复段落
【发布时间】:2013-12-17 17:56:22
【问题描述】:

我写了一个期望脚本来登录一些路由并运行sh inv 命令,但输出也 包含以下内容:

********************************* Access Warning!! ***********************************
*                                                                                    *
* This computer system, its network and data contained therein is the property of    *
* the <Company name>. Access to this computer and network is restricted              *
* to persons and programs authorised by the Group only. Access by others is          *
* prohibited and unauthorised, and is wrongful under law. Do not proceed if you      *
* are not authorised. Any unauthorised access will be prosecuted to the fullest      *
* extent of the law.                                                                 *
*                                                                                    *
**************************************************************************************

我可以使用 RegEx 从文本文件中删除上述重复出现的段落吗?

【问题讨论】:

  • 你使用什么语言?
  • 你违反了什么法律?
  • 我正在使用 Shell 脚本/bash

标签: regex


【解决方案1】:

this answer看来你可以使用Linux命令sed

从那里,上面的文本可以与正则表达式匹配:

\*{33} Access Warning!! \*{35}.*\*{86}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-05
    • 1970-01-01
    • 1970-01-01
    • 2016-03-30
    • 2021-04-18
    • 1970-01-01
    相关资源
    最近更新 更多