For consecutive lines with the same second fields,
print the first one and discard the others.
2007.01.11
Description
- Each line of the datafile consists of two fields separated by a colon.
- A block consists of consecutive lines whose second fields are the same.
- For each block, print the first line of the block and discard the others.
|
| Raw Input
|
| Desired Output
| 0003~4330:Abraham
0003~ 293:Abraham
0003~2464:Abraham
0003~2284:Abt
0003~2286:Abt
0003~3446:Abt-Bloch
0057~2288:van Rhyn
0057~2289:van Rhyn
0310~4417:Von Newman
|
| 0003~4330:Abraham
0003~2284:Abt
0003~3446:Abt-Bloch
0057~2288:van Rhyn
0310~4417:Von Newman
|
|
Script and Comments
Script1 [ 1] :loop
[ 2] N
[ 3] s/^([^:]*:([^\n]*))\n[^:]*:\2$/\1/
[ 4] t loop
[ 5] P
[ 6] D
| |
|