In the awk
below I am trying to copy the entire contents of $6
there may be multiple values seperated by a ;
, to $8
, if $8
is .
(lines 1 and 3 are examples). If that condition $8
is not .
(line2 is an example) then that line is skipped and printed as is. The awk
does execute but prints the output without changing file
to the desired output. Thank you :).
file tab-delimeted
R_Index Chr Start Func.refGene Gene.refGene GeneDetail.refGene ExonicFunc.refGene AAChange.refGene
1 chr1 17313157 splicing ATP13A2 NM_001141973:exon28:c.3221-30C>T:p=?;NM_022089:exon28:c.3236-30C>T:p=? . .
2 chr1 17313157 exonic ATP13A2 . nonsynonymous SNV ATP13A2:NM_001141974:exon27:c.3214G>A:p.Ala1072Thr
3 chr1 17313165 splicing ATP13A2 NM_001141973:exon28:c.3221-30C>T:p=? . .
awk
awk 'BEGIN {OFS=FS="\t"} {if ($8==".")sub($8,$6); print }' file
desired output tab-delimeted
R_Index Chr Start Func.refGene Gene.refGene GeneDetail.refGene ExonicFunc.refGene AAChange.refGene
1 chr1 17313157 splicing ATP13A2 NM_001141973:exon28:c.3221-30C>T:p=?;NM_022089:exon28:c.3236-30C>T:p=? . NM_001141973:exon28:c.3221-30C>T:p=?;NM_022089:exon28:c.3236-30C>T:p=?
2 chr1 17313157 exonic ATP13A2 . nonsynonymous SNV ATP13A2:NM_001141974:exon27:c.3214G>A:p.Ala1072Thr
3 chr1 17313165 splicing ATP13A2 NM_001141973:exon28:c.3221-30C>T:p=? . NM_001141973:exon28:c.3221-30C>T:p=?