Aqui está a awk
solution:
$ awk '
$4 < 1.5 {
uniq[$1] = $3;
uniq[$2] = $3;
next;
}
{
uniq[$1] = $3;
dup[$2] = $3;
delete uniq[$2];
}
END {
print "--unique.txt--";
for(i in uniq) {
print i,uniq[i]
}
print "";
print "--duplicate.txt--";
for(i in dup) {
print i,dup[i]
}
}' file
--unique.txt--
764157 ericcartman
56797854 ericcartman
53723848 timburnes
--duplicate.txt--
53530214 timburnes
52986038 ericcartman
12651711 timburnes
Com o seu segundo exemplo:
$ awk '
$4 < 1.5 {
uniq[$1] = $3;
uniq[$2] = $3;
next;
}
{
uniq[$1] = $3;
dup[$2] = $3;
delete uniq[$2];
}
END {
print "--unique.txt--";
for(i in uniq) {
print i,uniq[i]
}
print "";
print "--duplicate.txt--";
for(i in dup) {
print i,dup[i]
}
}' << END
> 17412193 43979400 ericcartman 2.16667
> 21757330 54678379 andrewruss 0.55264
END
--unique.txt--
21757330 andrewruss
54678379 andrewruss
17412193 ericcartman
--duplicate.txt--
43979400 ericcartman