Split file with 800,000 columns

前端 未结 1 1876
灰色年华
灰色年华 2021-01-20 09:12

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:55

    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)
提交回复
热议问题