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
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.