Description
- Given a datafile where each line is of the form
KEY=value.
- There may be several lines with a given key.
In this case, we want to delete all but the last line with that key.
|
| Raw Input
|
| Desired Output
| javascript=20
php=15
perl=30
algorithm=18
javascript=14
perl=39
java=88
data structure=40
operating systems=70
algorithm=15
perl=55
operating systems=100
|
| operating systems=100
perl=55
algorithm=15
data structure=40
java=88
javascript=14
php=15
|
|
Script and Comments
Script1 [ 1] 1{
[ 2] h
[ 3] d
[ 4] }
[ 5] G
[ 6] s/^(([^=]+)=[^\n]*)(.*)\n\2=[^\n]*/\1\3/
[ 7] $!{
[ 8] x
[ 9] d
[10] }
| |
Script2 [ 1] 1h
[ 2] G
[ 3] s/^(([^=]+)=[^\n]*)(.*)\n\2=[^\n]*/\1\3/
[ 4] $!{
[ 5] x
[ 6] d
[ 7] }
| |