【发布时间】:2020-10-29 20:13:52
【问题描述】:
我有一个制表符分隔文件
NC_044998.1 3778 0 CC 0 CC 0 CC 0 CC 1 CT 0 CC 0 CC 0 CC 0 CC 1 CT 0 CC var heterozygous varvar 9 0.818182 2 0.181818 refref refref refref refref refdev refref refref refref refref refdev refref homo homo homo homo het homo homo homo homo het homo 9 0 2 0 9 2
NC_044998.1 3787 0 CC 0 CC 1 CG 0 CC 0 CC 0 CC 0 CC 0 CC 0 CC 0 CC 0 CC var heterozygous varvar 10 0.909091 1 0.0909091 refref refref refdev refref refref refref refref refref refref refref refref homo homo het homo homo homo homo homo homo homo homo 10 0 1 0 10 1
$32-$43 的列有某种信息 (ref/dev),而$43-$54 的列有另一个 (homo/het)
我想合并它们,以便 col $32 与 col $32 + 11 = $43 合并并附加到文件的末尾,然后移动 i + 1,以便合并 $33$44 并附加,然后是$34$45,依此类推。
输出看起来像
NC_044998.1 3778 0 CC 0 CC 0 CC 0 CC 1 CT 0 CC 0 CC 0 CC 0 CC 1 CT 0 CC var heterozygous varvar 9 0.818182 2 0.181818 refref refref refref refref refdev refref refref refref refref refdev refref homo homo homo homo het homo homo homo homo het homo 9 0 2 0 9 2 refrefhomo refrefhomo refrefhomo refrefhomo refdevhet refrefhomo refrefhomo refrefhomo refrefhomo refdevhet refrefhomo
NC_044998.1 3787 0 CC 0 CC 1 CG 0 CC 0 CC 0 CC 0 CC 0 CC 0 CC 0 CC 0 CC var heterozygous varvar 10 0.909091 1 0.0909091 refref refref refdev refref refref refref refref refref refref refref refref homo homo het homo homo homo homo homo homo homo homo 10 0 1 0 10 1 refrefhomo refrefhomo refdevhet refrefhomo refrefhomo refrefhomo refrefhomo refrefhomo refrefhomo refrefhomo refrefhomo
我可以一个一个的
cut -f32,43 file | sed 's/ //g' | paste file - > file.tmp
但它会生成 11 个 tmp 文件
【问题讨论】: