rhnaeco
Technical User
- Aug 11, 2005
- 45
Hi, i need a bit of help sorting out my script:
awk '
BEGIN {
while (getline < "file1") {
cnt[$1]=$1
dep[$1]=$2
}
}
{
if (cnt[$1] = $1)
if ((dep[$1] < $2+0.4) && (dep[$1] > $2-0.4))
print $1, $2, dep[$1], $3, $4
}' file2 > file3
lines from file1:
486 -0.35 0.317856 88.95
486 -0.85 2.36172 88.95
486 -1.35 8.54376 88.95
486 -1.85 26.4533 88.95
486 -2.35 88.6047 88.95
lines from file2:
486 -1.47 38.1073 90.9
486 -1.97 34.7981 88.95
487 -1.47 37.7255 90.675
487 -1.97 34.4588 88.75
488 -1.47 35.6891 89.47
what i want the script to do is:
if cnt[$1] equals $1 in file2 (F2), then print $1(F2), $2(F2), $3(F1) if $2(F2) is within +/- 0.4 of $2(F2), $4
file3 (in theory- the same number of lines as file2):
486 -1.47 8.54376 90.9
486 -1.97 26.4533 88.95
487 -1.47 ?????? 90.675
487 -1.97 ?????? 88.75
488 -1.47 ?????? 89.47
thanks in advance
rhnaeco
awk '
BEGIN {
while (getline < "file1") {
cnt[$1]=$1
dep[$1]=$2
}
}
{
if (cnt[$1] = $1)
if ((dep[$1] < $2+0.4) && (dep[$1] > $2-0.4))
print $1, $2, dep[$1], $3, $4
}' file2 > file3
lines from file1:
486 -0.35 0.317856 88.95
486 -0.85 2.36172 88.95
486 -1.35 8.54376 88.95
486 -1.85 26.4533 88.95
486 -2.35 88.6047 88.95
lines from file2:
486 -1.47 38.1073 90.9
486 -1.97 34.7981 88.95
487 -1.47 37.7255 90.675
487 -1.97 34.4588 88.75
488 -1.47 35.6891 89.47
what i want the script to do is:
if cnt[$1] equals $1 in file2 (F2), then print $1(F2), $2(F2), $3(F1) if $2(F2) is within +/- 0.4 of $2(F2), $4
file3 (in theory- the same number of lines as file2):
486 -1.47 8.54376 90.9
486 -1.97 26.4533 88.95
487 -1.47 ?????? 90.675
487 -1.97 ?????? 88.75
488 -1.47 ?????? 89.47
thanks in advance
rhnaeco