【问题标题】:Using ed line editor for matching lines with a regular expression使用 ed 行编辑器将行与正则表达式匹配
【发布时间】:2021-12-08 11:21:47
【问题描述】:

我正在尝试将ed 命令与正则表达式一起使用

参与者.txt

#Team:Volgnummer:Nationaliteit:Auto:Klasse
DECONINCK Nico - DECONNINCK Gregory:0:B/B:OPEL Kadett:1A
DECONINCK Harry - Verhelst Jos:1:B/B:OPEL Kadett:1A
DEBRUYNE Jurgen - DERIEMAEKER Jolien :2:B/B :LADA Samara :1A
ROMMELAERE Michel - DEVOS Ingrid :3:B/B :TOYOTA Corolla :1A
DIERCKX Guy - NIETVELT Werner :4:B/B :TOYOTA Corolla :1A
HAMIAUX Bjorn -:5:B/ :HONDA Civic :1A
VAN GRASDORFF David - BRAEM Theo :6:B/B :HONDA Civic :1A

如果我在 bash shell 中运行 ed -s participants.txt,则为 ex ^D.*A$ 键入正则表达式。我得到了?

我的表情有什么问题。

【问题讨论】:

  • ^D.*A$ 不是 ed 命令。阅读 GNU ed 手册。

标签: linux shell unix sh ed


【解决方案1】:

您的意思是在ed 中使用regular expressions 吗?您需要在 g/<re>/ 语法中定义它才能工作,例如以下可以工作

ed -s participants.txt <<< 'g/^D.*A/'

【讨论】:

    猜你喜欢
    • 2016-02-16
    • 2022-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多