file too large
Richard O'Keefe
ok at cs.mu.oz.au
Sun Sep 17 20:51:44 AEST 1989
In article <2388 at netcom.UUCP>, beaulieu at netcom.UUCP (Bob Beaulieu) writes:
> I have a text file that is very large (26,000+ lines) and would like
> to break it down to 5-6 smaller files.
If you have split, it may do what you want:
split -5000 foobaz
where foobaz contains 26,123 lines, will create
xaa # lines 1- 5,000
xab # lines 5,001-10,000
xac # lines 10,001-15,000
xad # lines 15,001-20,000
xae # lines 20,001-25,000
xaf # lines 25,001-26,123
If you want 'zabbo' used as the prefix instead of 'x', say
split -5000 foobaz zabbo
and you'll get zabbo{aa,ab,ac,ad,ae,af} produced instead.
If you haven't got split, I can mail a version which is rather sexier.
Of course you could always do this with 'awk', use
awk -f split-5000-by-6.awk foobaz
where the file split-5000-by-6.awk contains these lines:
1 <= NR && NR <= 5000 { print $0 > "xaa" }
5001 <= NR && NR <= 10000 { print $0 > "xab" }
10001 <= NR && NR <= 15000 { print $0 > "xac" }
15001 <= NR && NR <= 20000 { print $0 > "xad" }
20001 <= NR && NR <= 25000 { print $0 > "xae" }
25001 <= NR && NR <= 30000 { print $0 > "xaf" }
There Is Always Another Way...
More information about the Comp.unix.questions
mailing list