Description
- The datafile consists of blocks and separating lines.
- The first line of every block is of the form
interface name.
Every remaining line of a block begins with non-exclamation-mark
character.
- A separating line consists of only one character: the exclamation mark('!').
We want to add a trailing line end-of-block after
each block.
|
| Raw Input
|
| Desired Output
| !
!
interface Loopback0
ip address 10.6.6.190 255.255.255.252
!
interface GigabitEthernet5/1
ip address 10.6.7.234 255.255.255.252
ip access-group 113 in
ip access-group 113 out
!
interface GigabitEthernet5/2
ip address 10.6.8.238 255.255.255.252
ip access-group 113 in
ip access-group 113 out
!
|
| !
!
interface Loopback0
ip address 10.6.6.190 255.255.255.252
end-of-block
!
interface GigabitEthernet5/1
ip address 10.6.7.234 255.255.255.252
ip access-group 113 in
ip access-group 113 out
end-of-block
!
interface GigabitEthernet5/2
ip address 10.6.8.238 255.255.255.252
ip access-group 113 in
ip access-group 113 out
end-of-block
!
|
|
Script and Comments
Script1 [ 1] /^interface/!b
[ 2] :loop
[ 3] $!{
[ 4] N
[ 5] /\n!$/!b loop
[ 6] }
[ 7] s/\n!$/\nend-of-block&/
| |
|