Reputation: 461
I have a text like this
5834589
MDL-BLABLABLA1
bla-bla2
bla-bla3
bla-bla4
bla-bla5
I want to replace 5834589 (number) in the line before line with the pattern MDL to EXAMPLE-RIVER-5834589 (Just add EXAMPLE-RIVER-).
Any suggestions with sed?
Upvotes: 0
Views: 1286
Reputation: 58578
This might work for you (GNU sed):
sed '$!N;s/^.*\n.*MDL/EXAMPLE-RIVER-&/;P;D' file
Upvotes: 2