rhnaeco
Technical User
- Aug 11, 2005
- 45
I have two files both with a structure like
12.7244 45.4828 -16.099
12.7249 45.4985 -12.45
12.7253 45.4888 -14.797
12.7257 45.5045 -11.79
12.7261 45.4948 -13.767
12.7265 45.4851 -15.631
I would like awk/sed to search the lines of one file and if $1 and $2 match with $1 and $2 in the other file. If they match i would like it to print to a third file, $0 plus $3 of the other file.
e.g.
(12.7265 45.4851 -15.631 -12.45)
Reading through the other posts i have figured out the first part, but not to print $3 on the same line
awk -F: '
BEGIN {
while (getline < "file1.dat") {
long[$1]=1
}
}
{
if (long[$1])
print $0
}
' file2.dat > output.dat
Thanks in advance
rhnaeco
12.7244 45.4828 -16.099
12.7249 45.4985 -12.45
12.7253 45.4888 -14.797
12.7257 45.5045 -11.79
12.7261 45.4948 -13.767
12.7265 45.4851 -15.631
I would like awk/sed to search the lines of one file and if $1 and $2 match with $1 and $2 in the other file. If they match i would like it to print to a third file, $0 plus $3 of the other file.
e.g.
(12.7265 45.4851 -15.631 -12.45)
Reading through the other posts i have figured out the first part, but not to print $3 on the same line
awk -F: '
BEGIN {
while (getline < "file1.dat") {
long[$1]=1
}
}
{
if (long[$1])
print $0
}
' file2.dat > output.dat
Thanks in advance
rhnaeco