Split file with 800,000 columns

前端 未结 1 1200
Happy的楠姐
Happy的楠姐 2021-01-20 09:17

I want to split a file of genomic data with 800,000 columns and 40,000 rows into a series of files with 100 columns each, total size 118GB.

I am currently running th

1条回答
  •  春和景丽
    2021-01-20 09:50

    Try this awk script:

    awk -v cols=100 '{ 
         f = 1 
         for (i = 1; i <= NF; i++) {
           printf "%s%s", $i, (i % cols && i < NF ? OFS : ORS) > (FILENAME "." f)
           f=int(i/cols)+1
         }
      }' largefile
    

    I expect it to be faster than the shell script in the question.

    0 讨论(0)
提交回复
热议问题