I have data file looks like:12 4 5 6 7 19202224 26 27 29 30 31 32 34 40 50 56 58234 235 270 5001234 1235 1236 12372300I want to split those rows with more than 4 column to smaller rows with maximum 4 columns within each row. therefore the  output should be: 1 2 4 5 6  7 19 20 22 24 26 27  29 30 31 32 34 40 50 56 58 234 235 270 500 1234 1235 1236 1237 2300Any suggestion please? Please consider that my real data file is huge.
How to split rows in a huge data file based on number of column within them in linux ?
linux;text processing;awk
With awk:awk '{ if(NF>4) for(i=5; i<=NF; i+=4) $i = \n $i } 1' fileWith sed:sed 's/ /\n/4;T;P;D' fileWith perl:perl -lpe '$c = 0; s/ /++$c % 4 ?   : \n/goe' fileOutput:12 4 5 6 7 19202224 26 27 29 30 31 32 34 40 50 56 58234 235 270 5001234 1235 1236 12372300