Hi,
I want to add new values to a site file form another sitefile. How to do this with awk?
I'm thinking it's got to be somethhing like:
awk F=|, /*? {$3} file1 | cat file2
Somebody got an idea? It's not completely right, but how to specify the columns in the second file, actualy create column in second file?
greetings Sjors
Sjors said:
Hi,
I want to add new values to a site file form another sitefile. How to do
this with awk?
I'm thinking it's got to be somethhing like:
awk F=|, /*? {$3} file1 | cat file2
Somebody got an idea? It's not completely right, but how to specify the
columns in the second file, actualy create column in second file?
I'm not sure I understand completely what you want to do:
file 1
0.000|0.000|#1 %5
file 2
12.3
result
0.000|0.000|#1 %5 %12.3
OR
file 1
0.000|0.000|#1 %5
file 2
1.000|1.000|#2 %12.3
result
0.000|0.000|#1 %5
1.000|1.000|#2 %12.3
If the first, try paste, if the second try cat>>
Moritz
Moritz Lennert wrote:
Sjors said:
Hi,
I want to add new values to a site file form another sitefile. How to do
this with awk?
I'm thinking it's got to be somethhing like:
awk F=|, /*? {$3} file1 | cat file2
Somebody got an idea? It's not completely right, but how to specify the
columns in the second file, actualy create column in second file?
I'm not sure I understand completely what you want to do:
file 1
0.000|0.000|#1 %5
file 2
12.3
result
0.000|0.000|#1 %5 %12.3
I made it this one. By first getting file 2 to be in 12.3 format (and not the orginal site file format 0.000|0.000|%12.3) with awk -F| {print #3} file 2 > test1.
Then I did paste with paste -d ' | ' file1 test1. Just thought it might be done easier but this it I think. Maybe put it all in a script. Orginating idea is the following. I've made a dem with contourlines converted to sites. Then because of segmented views I used r.random to get more sites. Now these random sites and contoursites give adequate dem. On the dem with r. mapcalc for different soil types I adjusted the depth of soils (so dem for soiltype A = dem - depth). Now for the same sites I want to have dem-depth for reinterpolation.
Thanks anyway, it's working.