Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!uhccux!munnari.oz.au!cs.mu.oz.au!ok From: ok@cs.mu.oz.au (Richard O'Keefe) Newsgroups: comp.unix.questions Subject: Re: file too large Summary: use split(1) Keywords: vi can't read file - help? Message-ID: <2121@munnari.oz.au> Date: 17 Sep 89 10:51:44 GMT References: <2388@netcom.UUCP> Sender: news@cs.mu.oz.au Lines: 28 In article <2388@netcom.UUCP>, beaulieu@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...