Sed pattern help - not FreeBSD related

Christoph Kukulies kuku at kukulies.org
Tue Aug 25 21:02:50 UTC 2020


Excuses, the result should look like: (forgot the DC)

> LOOP:   DC LOOP+2
> DO:	      DC DO+2
> J:	     DC J+2
> ENCL:	DC ENCL+2  PDP-11 VERSION OF ENCLOSE
> KEY	     DC KEY+2
> EMIT	DC EMIT+2
> QTERM	DC QTERM+2


> Am 25.08.2020 um 22:00 schrieb Christoph Kukulies <kuku at kukulies.org>:
> 
> Excuses for asking a sed problem only without relation to FreeBSD:
> 
> I have a file el2 with the following content:
> 
> LOOP:	DC *+2
> DO:	DC *+2
> J:	DC *+2
> ENCL:	DC *+2  PDP-11 VERSION OF ENCLOSE
> KEY	DC *+2
> EMIT	DC *+2
> QTERM	DC *+2

> With a sed command I will make it become:
> 
> LOOP:   DC LOOP+2
> DO:	      DC DO+2
> J:	     DC J+2
> ENCL:	DC ENCL+2  PDP-11 VERSION OF ENCLOSE
> KEY	     DC KEY+2
> EMIT	DC EMIT+2
> QTERM	DC QTERM+2
> 
> In other words, the "*" should be replaced by the label in front of the line.
> In case the line contains something after "+2“ (a comment), it should be appended.
> 
> The following sed command doesn’t work. Please no awk,perl,python or other script :)
> 
> $ sed  's/\(^[A-Z0-9]*\)\(:?\)\([ \t]*\)\(DC \*\+2\)\(.*$\)/\1\2\3DC \1+2/\5’ <el2
> 
> 
> Thanks in advance,
> 
>> Christoph
> 
> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3363 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20200825/3aacf04b/attachment.bin>


More information about the freebsd-questions mailing list