Hi All,
I have two files.
First file "Chris1.txt"
ckb+:05 17468668 ds09
ckb+:05 1549368 ss09
cup+:03 3654311 ds09
cup+:03 266059 ss09
eel+:04 15392852 ds09
eel+:04 944131 ss09
Second File "Chris2.txt"
ckb+:05 1532093 -827330.22 457510330 26 26 0 ss09
ckb+:05 17390749 38374660.98 1892708517 16395 62 1 ds09
cup+:03 3603298 8126919.54 424256233 3454 78 16 ds09
cup+:03 263078 -142062.12 107577691 0 0 0 ss09
eel+:04 15344006 32111482.32 1874911075 10695 32 1 ds09
eel+:04 933544 -504113.76 398094666 3 3 0 ss09
Desired Output should be
ckb+:05 1549368 1532093 -827330.22 457510330 26 26 0 ss09
ckb+:05 17468668 38374660.98 1892708517 16395 62 1 ds09
I need to compare first $1 and $8 and if true print $1,($2 of Chris1.txt),$2,$3,$4,$5,$6,$7,$8.
Script
awk -v file="Chris1.txt" 'BEGIN{
if(!file)file="Chris1.txt"
while((getline<fn)>0){
a[$1]=$1;b[$1]=$3
}
}
{
if(a[$1])&&(b[$8])
print $1,b[$1],$2,$3,$4,$5,$6,$7,$8
}' Chris2.txt
Many Thanks
Chris
I have two files.
First file "Chris1.txt"
ckb+:05 17468668 ds09
ckb+:05 1549368 ss09
cup+:03 3654311 ds09
cup+:03 266059 ss09
eel+:04 15392852 ds09
eel+:04 944131 ss09
Second File "Chris2.txt"
ckb+:05 1532093 -827330.22 457510330 26 26 0 ss09
ckb+:05 17390749 38374660.98 1892708517 16395 62 1 ds09
cup+:03 3603298 8126919.54 424256233 3454 78 16 ds09
cup+:03 263078 -142062.12 107577691 0 0 0 ss09
eel+:04 15344006 32111482.32 1874911075 10695 32 1 ds09
eel+:04 933544 -504113.76 398094666 3 3 0 ss09
Desired Output should be
ckb+:05 1549368 1532093 -827330.22 457510330 26 26 0 ss09
ckb+:05 17468668 38374660.98 1892708517 16395 62 1 ds09
I need to compare first $1 and $8 and if true print $1,($2 of Chris1.txt),$2,$3,$4,$5,$6,$7,$8.
Script
awk -v file="Chris1.txt" 'BEGIN{
if(!file)file="Chris1.txt"
while((getline<fn)>0){
a[$1]=$1;b[$1]=$3
}
}
{
if(a[$1])&&(b[$8])
print $1,b[$1],$2,$3,$4,$5,$6,$7,$8
}' Chris2.txt
Many Thanks
Chris