I am writing a PHP script to parse a large text file to do 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 head ( tail -4001 file.txt | head -4000 > section2.txt ), but is there another/better way?
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

splitwill split the file into three chunks, only one of which one cares about, surely thesedanswer is preferable. – cbmanica Oct 01 '21 at 16:17