I am looking for some options in unix (may be awk or sed ) through which I can replace the last column in my .fam file with the last column (v8) of a .txt file. Something similar to the merge function in R.
My .fam file looks like this
20481 20481 0 0 2 -9
20483 20483 0 0 1 1
20488 20488 0 0 2 1
20492 20492 0 0 1 1
and my .txt file looks like this.
V1 V2 V3 V4 V6 V7_Pheno V8
2253792 20481 NA DNA 1 Yes 2
2253802 20483 NA DNA 4 Yes 2
2253816 20488 NA DNA 0 No 1
2253820 20492 NA DNA 4 Yes 2
My outcome.fam file should looks like this
20481 20481 0 0 2 2
20483 20483 0 0 1 2
20488 20488 0 0 2 1
20492 20492 0 0 1 2
pastemerges the linesawkallow you to select column, soshould do what you want
If you want to suppress the header line of
.txtfile, you can calltailto skip the first line:tail -n +2 bar.txtYou can hence integrate it in you command line (assuming you use
bash)