Description
Here we define 'block' as a set of consecutive lines which contain
some string, for example '<OPTION>'.
Now we want to add a line '---End of options---' to the end of every block.
|
| Raw Input
| The main Linux distributions are:
<OPTION> Red Hat
<OPTION> Mandrake
<OPTION> SuSE
<OPTION> Slackware
Main window manager used in Linux are:
<OPTION> Sawfish
<OPTION> enlightenment
<OPTION> fvwm
|
|
| Desired Output
| The main Linux distributions are:
<OPTION> Red Hat
<OPTION> Mandrake
<OPTION> SuSE
<OPTION> Slackware
---End of options---
Main window manager used in Linux are:
<OPTION> Sawfish
<OPTION> enlightenment
<OPTION> fvwm
---End of options---
|
|
Script and Comments
Script1 [ 1] /<OPTION>/{
[ 2] $!N
[ 3] P
[ 4] /\n.*<OPTION>/!i\
[ 5] ---End of options---
[ 6] D
[ 7] }
| |