Description
Given a datafile where
- Each line consists of four fields separated by colons.
- Fields may be padded with spaces.
- We want to print consecutive lines with the same fields.
In this case, lines whose fields are `1001', `1028', `1032', and `1437'
have to be printed.
|
| Raw Input
|
| Desired Output
| 099 :213 :126 :0250:EOP099
1001 :66 :128 :0250:1001
1001 :73 :168 :0250:1001-1
1001C :66 :168 :0250:1001-2
1003 :73 :168 :0250:1003
1011 :73 :168 :0300:1011
1028 :66 :126 :0250:1028
1028 :66 :168 :0250:1028-1
1030 :73 :168 :0300:1030
1032 :105 :168 :0345:1032
1032 :105 :168 :0380:1032-1
1033C :09 :126 :0250:1033
1437 :408 :128 :0305:1437
1437 :571 :128 :0305:1437-1
1437 :574 :130 :0305:1437-2
|
| 1001 :66 :128 :0250:1001
1001 :73 :168 :0250:1001-1
1028 :66 :126 :0250:1028
1028 :66 :168 :0250:1028-1
1032 :105 :168 :0345:1032
1032 :105 :168 :0380:1032-1
1437 :408 :128 :0305:1437
1437 :571 :128 :0305:1437-1
1437 :574 :130 :0305:1437-2
|
|
Script and Comments
Script1 [ 1] $!N
[ 2] /^\([^:]*:\).*\n\1/!D
[ 3] :loop
[ 4] P
[ 5] s/^.*\n//
[ 6] $!N
[ 7] /^\([^:]*:\).*\n\1/b loop
[ 8] P
[ 9] D
| |