Description
We want to perform a specific operation on lines range from the beginning
of a file till the last line containing `PAT'.
In this example, the specific operation is replacing `this' with `that'.
|
| Raw Input
|
| Desired Output
| ..
PAT
..replace this.
..replace this.
PAT
..replace this.
..replace this.
PAT reeplace this.
..keep this.
..keep this.
|
| ..
PAT
..replace that.
..replace that.
PAT
..replace that.
..replace that.
PAT replace that.
..keep this.
..keep this.
|
|
Script and Comments
Script1 [ 1] :loop
[ 2] /PAT/!{
[ 3] $!N
[ 4] $!b loop
[ 5] }
[ 6] /PAT/s/this/that/g
| |