I just encountered with a question. It is very similar to what I already asked before how to copy a column from another file when the ID's matches, with some differences.
I have a folder (folder1), with multiple files:
desired_pos142535974
desired_pos142540918
desired_pos142541687
desired_pos142541814
desired_pos142541910
desired_pos142542976
head file looks like this
head desired_pos142535974
1 142535974 196 HG00100
1 142535974 64 HG00101
1 142535974 63 HG00103
1 142535974 26 HG00108
1 142535974 85 HG00110
1 142535974 83 HG00114
1 142535974 148 HG00115
I have another folder (folder2)
desired_output_pos142535974_g
desired_output_pos142540918_g
desired_output_pos142541687_g
desired_output_pos142541814_g
desired_output_pos142541910_g
desired_output_pos142542976_g
each file in the folder2 looks like this
head desired_output_pos142535974_g
HG00096 0|1
HG00097 1|0
HG00099 0|1
HG00100 1|0
HG00101 0|1
HG00102 0|1
HG00103 1|1
each file in folder 1 has an identical file in the folder 2 with the same "pos...." ID (for example desired_pos142535974 and desired_output_pos142535974_g both belong to the same individual).
So, this time I want to check if the last column of a file in folder 1 matches the first column of a file in folder 2 with the identical "pos" ID, add the second column of file 2 to file1, ending up with something like
head desires_pos142535974
1 142535974 196 HG00100 1|0
1 142535974 64 HG00101 0|1
1 142535974 63 HG00103 1|1