Using awk to replace a block on a text file

Hello people,
If you need to replace a text block on a file you may use awk with the following sintax:
awk ‘/start/{f=1;print;while (getline < “replace.txt”){print}}/end/{f=0}!f’ datafile.txt

where datafile.txt:

bla bla bla
<start>
ble ble ble
ble ble ble
<end>
blo blo

and replace.txt like:

TEST OK

the outcome should be:

bla bla bla
<start>
TEST OK
<end>
blo blo

Cheers,
Pedro Oliveira

Click to access the login or register cheese