Black Friday 2025 – NPI EA (cat = Baeldung on Linux)
announcement - icon

Yes, we're now running our Black Friday Sale. All Access and Pro are 33% off until 2nd December, 2025:

>> EXPLORE ACCESS NOW

Baeldung Pro – Linux – NPI EA (cat = Baeldung on Linux)
announcement - icon

Learn through the super-clean Baeldung Pro experience:

>> Membership and Baeldung Pro.

No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.

Partner – Orkes – NPI EA (tag=Kubernetes)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

1. Introduction

In this short tutorial, we’ll take a look at a few different ways we can split files in Unix systems.

All of these commands were tested in Bash, but are platform-independent.

2. Using split

One of the most common ways of splitting files is to divide them into chunks by a given size. To do this we can use the split command.

Let’s say we have a 50MB text file and we want to divide it into five 10MB parts. All we do is:

split --bytes=10M data.txt dataPartPrefix

This will result in creating five files with the following names:

dataPartPrefixa
dataPartPrefixb
dataPartPrefixc
dataPartPrefixd
dataPartPrefixe

Notice that our prefix name will be followed by the following letters. Adding -d to the command will use numeric suffixes starting from 0 instead of alphabetic ones.

The –bytes argument accepts integer values or a unit (example: 10K is 10*1024). Units are K, M, G, T, P, E, Z, Y for powers of 1024 or KB, MB, and so on for powers of 1000

We can also split a file into a given number of chunks with equal size.

split --number=2 data.txt dataPartPrefix

This will create two files with 5MB size each:

dataPartPrefixa
dataPartPrefixb

If we are splitting a text file and want to split it by lines we can do:

split -l 500 data.txt dataPartPrefix

This will result in a number of files depending on origin file content length.

To put the data back together we can use cat:

cat dataPartPrefix* > newData.txt

3. Splitting Files Using 7-Zip

We can also split a file while creating a 7-Zip archive. This will result in creating multiple archive volumes.

Let’s assume we have the same 50MB text file and we want to divide it into 10MB archives. All we do is:

7z a -v10m -mx0 data.7z data.tzt

The 10m is the volume size and -mx0 tells 7-Zip to use no compression.

After running this command we’ll have following files in our directory:

data.txt
data.7z.001
data.7z.002
data.7z.003
data.7z.004
data.7z.005

To get back the origin file we should simply extract the first volume:

7z x data.7z.001

7-Zip will automatically start extracting the remaining files in order.

4. Conclusion

In this tutorial, we’ve learned how to split files in Unix systems, having a look at both the split and 7-Zip commands.