| Raw Input
| |
File1:
| dye
knit
bkk
|
|
| Raw Input
|
| Desired Output
| |
File2: each line consists of three fields separated by commas.
| kabin:db:N
bkk:db:N
taipei:file:N
dye:file:N
knit:diskless:Y
dye:db:N
kabin:file:N
taipei:vpn:N
dye:vpn:Y
bkk:vpn:N
knit:file:Y
kabin:vpn:N
knit:vpn:N
|
| kabin:db:N
bkk:db:Y
taipei:file:N
dye:file:Y
knit:diskless:Y
dye:db:Y
kabin:file:N
taipei:vpn:N
dye:vpn:Y
bkk:vpn:Y
knit:file:Y
kabin:vpn:N
knit:vpn:Y
|
|
Description
For every line of File2, if its first field is listed
in File1, update the third field to `Y'.
|
Script and Comments
Script1 [ 1] /:/!{
[ 2] H
[ 3] d
[ 4] }
[ 5] G
[ 6] s/^(([^:]+):[^:]+):.\n.*\n\2(\n.*|$)/\1:Y/
[ 7] t
[ 8] s/\n.*//
| |
|