Split and Join file in Linux via terminal
Have ever wanted to split a big file or may be a normal file into multiple parts and later join them. Well, in Linux i would say that is quite easy by using split and cat commands in terminal.
Let’s try it with an example. Open terminal. If you want to read more, the easy way is the Linux man pages. Just type this, and you will get all the help related to split command. Same goes for other commands too.
split --help
Let’s say i have a file V-for-vendetta.mkv size of 367 MB in location /backup/Downloads/V-for-Vendetta/. 1st of i want to split this file into 100 MB each part.
cd /backup/Downloads/V-for-Vendetta
split -b100M V-for-Vendetta.mkv vendetta.mkv
M
represents megabytes, K
represents kilobytes and B
represents bytes. Even can use G
for gigabytes and T
for terabytes etc. Read help of split for more.
V-for-Vendetta.mkv is the name of the original file and the second one is the new file name. It will split it into 4 parts like vendetta.mkvaa, vendetta.mkvab, vendetta.mkvac, vendetta.mkvad.
Now is time to merge all the parts into one file again.
cat vendetta.mkv* > vendetta.mkv
Cat command will do the bits here, nothing fancy here to explain, its self explanatory. Read more about cat from man pages in terminal. Just note the * here, as we removed the aa, ab, ac, ad etc from the original parts name.
Happy splitting and joining.