Search code examples
linuxshellunixshed

Using ed line editor for matching lines with a regular expression


i am trying to use ed command in with regular expressions

participants.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

if i run the ed -s participants.txt in bash shell , then type a regular expression for ex ^D.*A$ . i got ?

what is the wrong with my expression .


Solution

  • Did you mean to use the regular expressions in ed? You need to define it in the g/<re>/ syntax for it to work, e.g. the following could work

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