11.7. Using split

Split allows you to divide large text files into smaller files. It’s surprising how quickly files can grow and, when you need to transfer files, it’s sometimes easier to split them up first. When using vi or other tools such as sort, you can have problems if the file is too big for the working buffer so sometimes you are not given a choice; you have to create smaller chunks out of the file.

Here is the general format of the split command:

split -output-file-size input-filename output-filename 

where output-file-size is the number of lines you want the file to be split by. When split looks at the file output-file-size option specified it will try to divide the files into 1 000 lines each. If we had a file containing 2 800 lines, ...

Get Linux and Unix Shell Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.