There are lots of tools available on PC (Windows) for splitting and joining files. There are very few available on Macintosh and Linux. But on Macintosh and Linux we don’t really need a separate tool for splitting and joining files the OS comes with one for us.
Splitting and joining files are pretty straight forward. There are two simple command line tools to do it. In this entire exercise we will be using only 3 command line tools.
1. Change Directory.
cd – change the current working directory to a specific Folder.
cd [-L | -P] [directory]
2. Splitting the File.
split — split a file into pieces
split [-a suffix_length] [-b byte_count[k|m]] [-l line_count]
[-p pattern] [file [name]]
3. Joining the File.
cat — concatenate and print files
cat [-benstuv] [file …]
Lets get down to business and start splitting the file.
I didn’t have any big file to try the commands on. So I compressed Google Chrome application.
Get into the folder containing the huge file using cd (change directory) command
split -b 50m “Google Chrome.app.zip” ChromePieces
“Google Chrome.app.zip” -> Name of the file to be split
ChromePieces -> Prefix of output file name.
-b -> Create smaller files byte_count bytes in length.
50 ->byte_count value.
m -> indicates megabyte pieces. k can be used instead for kilo-byte pieces
The zip file size was 93.1 MB. So it ended up creating two files. As can be seen from the image above.
cat ChromePieces* > Chrome.zip
We are joining all the files that have prefix file name “ChromePieces” and the resultant file will be created as Chrome.zip
A new (Chrome.zip) file is created.
You can unzip the Chrome.zip file and Google Chrome application extracted would work as normal. Split and cat can be used on most of the files. I have tried it on binaries(Application & Installers), Audio and Video Files, Text files.