單程awk。我不知道它是否(awk
)可以處理如此大量的列,但請試一試。它使用模數運算符爲每個特定數量的列削減行。
awk '{
## Print header of first line.
printf "%s%s%s%s", $1, FS, $2, FS
## Count number of columns printed, from 0 to 100.
count = 0
## Traverse every columns but the first two keys.
for (i = 3; i <= NF; i++) {
## Print header again when counted 100 columns.
if (count != 0 && count % 100 == 0) {
printf "%s%s%s%s%s", ORS, $1, FS, $2, FS
}
## Print current column and count it.
printf "%s%s", $i, FS
++count
}
## Separator between splits.
print ORS
}
' infile
我兩條線和4
列,而不是100
進行了測試。下面是測試文件:
key1 key2 one two three four five six seven eight nine ten
key1 key2 one2 two2 three2 four2 five2 six2 seven2 eight2 nine2 ten2
在
和結果:
key1 key2 one two three four
key1 key2 five six seven eight
key1 key2 nine ten
key1 key2 one2 two2 three2 four2
key1 key2 five2 six2 seven2 eight2
key1 key2 nine2 ten2
什麼軟件在其右側的腦海裏輸出1.5M列(你平均值m爲百萬或M在羅馬數字?爲1000?)(無論哪種方式它的瘋狂,只是不同的數量級;-))。難道你不能通過另一種方式獲得數據:50列,150M行嗎?祝你好運! – shellter