![Como substituir uma string correspondente em um arquivo pela string correspondente em outro arquivo?](https://rvso.com/image/170255/Como%20substituir%20uma%20string%20correspondente%20em%20um%20arquivo%20pela%20string%20correspondente%20em%20outro%20arquivo%3F.png)
Eu tenho um arquivo como este:
head cleandata.map
1 1:775852:T:C 0 775852
1 1:1120590:A:C 0 1120590
1 1:1145994:T:C 0 1145994
1 1:1148494:A:G 0 1148494
...
E outro arquivo:
head lifted.map
1 1:775852:T:C 0.0 785989
1 1:1120590:A:C 0.0 1130727
1 1:1145994:T:C 0.0 1156131
1 1:1148494:A:G 0.0 1158631
...
O que eu quero é alterar cleandata.map, que ficaria assim:
1 1:785989:T:C 0 785989
1 1:1130727:A:C 0 1130727
1 1:1156131:T:C 0 1156131
1 1:1158631:A:G 0 1158631
...
Portanto, se a linha na 2ª coluna de lifted.map corresponder à linha da 2ª coluna de cleandata.map, substitua a linha na 2ª e 4ª coluna e de cleandata.map pelo valor da 4ª coluna em lift.map.
Responder1
Tentar
$ awk 'FNR==NR {T[$2] = $4; next} $2 in T {gsub ($4, T[$2])} 1' file2 file1
1 1:785989:T:C 0 785989
1 1:1130727:A:C 0 1130727
1 1:1156131:T:C 0 1156131
1 1:1158631:A:G 0 1158631