Description
In the following example, many lines contain LIBS=,
we want to delete all but the last one of them.
|
| Raw Input
|
| Desired Output
| 1 LIBS=-lm
2 some other data
3 HEADERS=stdlib.h math.h
4 some other data
5 LIBS=-lz -lm
6 some other data
7 HEADERS=stdlib.h math.h zlib.h
8 some other data
9 LIBS=-lz -lm -ld
10 some other data
11 some other data
12 HEADERS=stdlib.h math.h zlib.h regex.h
13 some other data
|
| 2 some other data
3 HEADERS=stdlib.h math.h
4 some other data
6 some other data
7 HEADERS=stdlib.h math.h zlib.h
8 some other data
9 LIBS=-lz -lm -ld
10 some other data
11 some other data
12 HEADERS=stdlib.h math.h zlib.h regex.h
13 some other data
|
|
Script and Comments
Script1 [ 1] /LIBS=/!b
[ 2] :loop
[ 3] $q
[ 4] N
[ 5] /\n[^\n]*LIBS=[^\n]*$/!b loop
[ 6] s/^[^\n]*\n//
[ 7] h
[ 8] s/\n[^\n]*$//p
[ 9] x
[10] s/^.*\n//
[11] b loop
| |
|