Sed pattern help - not FreeBSD related

Christoph Kukulies kuku at kukulies.org
Tue Aug 25 20:01:04 UTC 2020


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:	DO+2
J:	J+2
ENCL:	ENCL+2  PDP-11 VERSION OF ENCLOSE
KEY	KEY+2
EMIT	EMIT+2
QTERM	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/bee3c25a/attachment.bin>


More information about the freebsd-questions mailing list