
2-file awk search-and-replace
Hi!
For my data-mining class I'm trying to learn how to use awk. I was able to
extract some data from a file and put it into a file with the following
layout:
5 Attcap-shape:s
6 Attcap-shape:x
7 Attcap-surface:f
8 Attcap-surface:g
9 Attcap-surface:s
10 Attcap-surface:y
11 Attcap-color:b
12 Attcap-color:c
13 Attcap-color:e
14 Attcap-color:g
the integer is a property-id and the text is it's description.
Now what I want to do is in another file, replace the different numbers by
their corresponding property-description. My second file is formatted like
this:
36 86 83 1.000 0.667
36 89 83 1.000 0.613
51 83 86 1.000 0.567
51 86 83 1.000 0.567
51 83 86 1.000 0.567
51 83 89 34 1.000 0.567
51 89 12 83 23 1.000 0.567
leftSideOfRule rightSideOfRule Accuracy Frequency
Concretely, what I want to do is, on each line, replace the (NF-2) fields
with their corresponding descriptions. I've been on this for the past 2
hours, and I can't seem to get it right. Should I maybe use sed or some
other util for this type of multi-file handling?
Thank you very much in advance,
Yannick
/// Yannick Wurm
/// Bioinformatique et Modelisation
/// Insa de Lyon