Using sed and/or awk, how can do a sed swap on all text in a file until I see a line matching a reg

Posted by Ross Rogers on Stack Overflow See other posts from Stack Overflow or by Ross Rogers
Published on 2010-03-25T23:54:58Z Indexed on 2010/03/26 0:03 UTC
Read the original article Hit count: 161

Filed under:
|
|

How can I do a sed regex swap on all text that preceed a line matching a regex.

e.g. How can I do a swap like this

s/foo/bar/g

for all text that precedes the first point this regex matches:

m/baz/

I don't want to use positive/negative look ahead/behind in my sed regex, because those are really expensive operations on big files.

© Stack Overflow or respective owner

Related posts about sed

Related posts about awk