linux - Copy a specific field of a file and paste it into another specific field of another existing file - lunx commands -


good afternoon everyone, have 2 files these:

file 1

45.999 60.9999 70.000 23.0090 

file 2

datafile pheno.txt traits fields_passed output  weight(s)  residual_variance  effect 2 cross alpha effect 1 cross alpha random animal file pedigree.txt snp_file snp_.txt (co)variances 

and need pass values of file 1 specific places of file 2 this:

file 2

datafile pheno.txt traits fields_passed output  weight(s)  residual_variance 45.999 effect 2 cross alpha effect 1 cross alpha random animal file pedigree.txt snp_file snp_.txt (co)variances 23.0090 

remembering, want keep file 2, add file 1 values

set -- $(<file1) sed -i "/residual_variance/{n;c$1 };\${s/[0-9].*/$4/;t;a$4 }" file2 

see man sed:

-i edit files in place


Comments