【问题标题】:grep -e command to Return matching datagrep -e 命令返回匹配数据
【发布时间】:2020-09-30 23:01:59
【问题描述】:

我正在使用 grep 命令检查输出模式。但我无法理解为什么下面的命令没有给出结果。 (据我所知 -e 用于匹配模式)

节点 App.js | grep -e "65"

但这是返回结果。那是-65。

节点 App.js | grep "65"

请注意> node App.js 文件的输出是65。

帮助我理解这里的问题。

【问题讨论】:

    标签: node.js linux shell grep


    【解决方案1】:

    你好

    -e 表示“使用简单的正则表达式”。一个简单的正则表达式是“^[a-zA-Z0-9].*$”。因此,您的脚本的输出是...

    node App.js | grep -o -e "[6][5]"
    

    ...你的朋友。还有一个扩展的正则表达式模式......

    node App.js | grep -o -E "[56]{2,2}"
    

    ...命中 55、66、56 和 65。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-07
      • 1970-01-01
      • 2021-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多