How to split files
Table of Contents
Learn how to split big files in several parts.
Split
split [<options>] <file> [<prefix>]
<prefix>: name prefix of the parts.splitwill add a couple of letters after this prefix. By default, prefix will be “x”.
$ split -n 3 bigfile bigfile.part
$ ls
bigfile bigfile.partaa bigfile.partab bigfile.partac
Some of the available options are:
-n <parts>: specify in how many parts you want to split the file.-l <lines>: number of lines per each output file.-b <size>: put<size>bytes per output file. You can use suffixes likeK,MorG.-d: use numeric suffixes instead of alphabetic (e.g.:bigfile.part01,bigfile.part02, etc.)
Reattach
You can use cat to reattach the files.
cat bigfile.part?? > bigfile
?is a RegExp parameter that means “one character”, sobigfile.part??expands to all files that start withbigfile.partand have exactly two characters more.- You don’t need to use RegExp:
cat bigfile.part01 bigfile.part02 > bigfile
tar
Check Backup methods (III): dd / tar.
Test with this online terminal:
If you have any suggestion, feel free to contact me via social media or email.
Latest tutorials and articles:
Featured content: