split a big file
Cut a big file into smaller pieces, by lines or by size, and join them again.
Steps
-
split -l 1000 big.txt part_pieces of 1,000 lines: part_aa, part_ab…
-
split -b 100M big.bin part_pieces of 100 MB
-
split -n 4 big.txt part_four pieces of equal size (GNU)
-
split -d -l 1000 --additional-suffix=.csv big.csv part_numbered pieces that keep the .csv ending (GNU)
-
cat part_* > big.txtjoin them again
Notes
- A CSV's header line goes only into the first piece.
Commands used
splitcatcsplit
Each has a page in lore: lore split opens it.
Related recipes
- compare two foldersFind which files differ between two folders, or are only in one of them.
- count lines, words and filesCount the lines of a file or of a command's output, the words, and the files in a folder.
- delete lines containing a textRemove every line of a file that contains a word, or keep only those lines.
- find files containing a textSearch every file under a folder for a word or a phrase, and show where it is.