Description
Get the N-th matched line.
In the following,
we want to get the 5-th line containing 'match'.
|
| Raw Input
|
| Desired Output
| ......
match-1
match-2...match-2....
.....
match-3...
.....
.....
match-4...
.....
match-5...
match-6...
|
| match-5...
|
|
Script and Comments
Script1 [ 1] /match/!d
[ 2] G
[ 3] s/(\n[^\n]*){5}$//
[ 4] /\n/!q
[ 5] x
[ 6] d
| |
|