Sed-Script to comment out lines between two multiline markers A\nB and U\nV

I have the file "test" with the content in (1). I want a sed script, that edits "test" so that i have the output in (2).

I cannot not simply do this:

cat test | sed -E '1,/B/!{/U/,$!s/.+/# &/}'

...because it would start commenting out beginning from first 'B' and not from 'A\nB'.

(1)

X
X

B

A
B

X
X
X

U

U
V

X
X

(2)

X
X

B

A
B

# X
# X
# X

# U

U
V

X
X


Comments

Popular posts from this blog

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept