No pages like "JoinFiles"!

Clear message

Join two files on a common field and re-arrange the output:

$ cat a.txt
cust1, ac1, 100
cust2, ac2, 200
$ cat b.txt
100000, cust1, 100
2000000, cust2, 200
$ join -a 1 -a 2 -1 3 -2 3 -t"," -o 1.1 1.2 1.3 2.1 a.txt b.txt
cust1, ac1, 100,100000
cust2, ac2, 200,2000000

the input files need to be sorted based on the comparison key

Using awk in a shell script

File1 = chr locations
File2 = GFF file

awk '
NR==FNR{
a[NR]=$0
next
}
{
for(i=1;i<NR;i++)
if (a[i] > $4 && a[i] < $5) print $2,$3, "falls between", $4 "and", $5 "at location", a[i]
}
' File1 File2 > Outfile_Chr1 &