Low Orbit Flux Logo 2 D

Linux How To Split And Join Files

If you need to move around large files you might find it useful to be able to both split and join files. You can split different types of files including binary data files ( executables, videos, music, text, etc. ).

Quick Answer: On Linux you can split and join files with these commands:

split -b 1M test.mp4    # split
cat x* > test.mp4       # join / combine

Keep reading for more details and examples.

We are going to be using the file rabbitmq-server-generic-unix-3.8.9.tar for most of the examples on this page.

How to Split Files on Linux

You can split a file into 1M chunks like this:

split -b 1M rabbitmq-server-generic-unix-3.8.9.tar

This will result in a bunch of 1M files that look like this:

xaa  xab  xac  xad  xae  xaf  xag  xah  xai  xaj  xak  xal  xam  xan  xao  xap

You could choose to provide a prefix for each split file. Just specify it as another parameter.

split -b 1M rabbitmq-server-generic-unix-3.8.9.tar test_

This will result in files that look like this:

test_aa  test_ab  test_ac  test_ad  test_ae  test_af  test_ag  test_ah  test_ai  test_aj  test_ak  test_al  test_am  test_an  test_ao  test_ap

Make sure to actually check which files were generated and don’t assume anything. You will want to keep track of these so that you can successfully recombine them later.

How to Join Files on Linux

Joining files back together is relatively easy.

If you didn’t specify a prefix you could join all of the files together like this:

cat x* > rabbitmq-server-generic-unix-3.8.9.tar

If you specified a prefix you could just do the following:

cat test_* > rabbitmq-server-generic-unix-3.8.9.tar

Just make sure that you match the actual files that you are trying to combine. It is easy to match unrelated files or to miss some of the files that you need to combine.

You could just combine everything in the current directory if you want. That would actually workout very well if you organize your files this way. Use the following command.

cat * > rabbitmq-server-generic-unix-3.8.9.tar

Linux - Split / Join Files - Video