I am writing a php script to parse a large text file do to database inserts from it. However on my host, the file is too large, and I hit the memory limit for php.
The file has about 16,000 lines; I want to split it up into four separate files (at first) to see if I can load those.
The first part I can get with
head -4000 file.txt. The middle sections are slightly trickier -- I was thinking about piping
tail output into
tail -4001 file.txt|head -4000 > section2.txt ), but is there another/better way?
Edit actually my logic is messed up -- for section two, I would need to so something like
tail -12001 file.txt|head - 4000, and then lower the
tail argument for the next sections. I'm getting mixed up already! :P