我有一个像这样的大文件
AT5G44030,TAACARA,1000,+,200,206
AT5G44030,TAACARA,1000,+,418,424
AT5G44030,TAACARA,1000,+,773,779
AT5G44030,NGATT,1000,+,114,118
AT5G44030,NGATT,1000,+,267,271
....................................
我想在最后添加两列,并减去 5th - 3rd 、 6th - 3rd ,因此最终文件应如下所示。
AT5G44030,TAACARA,1000,+,200,206,-800,-794
AT5G44030,TAACARA,1000,+,418,424,-582,-576
AT5G44030,TAACARA,1000,+,773,779,-227,-221
AT5G44030,NGATT,1000,+,114,118,-886,-882
AT5G44030,NGATT,1000,+,267,271,-733,-729
.......................................
(注意中间不能有空行)
我该如何使用awk
or来做到这一点sed
?该文件非常大—— 1M 行。
答案1
awk 'BEGIN { FS=OFS="," } {print $0,$5-$3,$6-$3}' my_file