Linux

How to split and join files into one in Ubuntu Linux using Split and Cat

Ubuntu is one of the most versatile open source operating systems with the most tools available today. This system allows you to perform a wide range of operations thanks to the functions that Ubuntu has or may have. One of them and very interesting is that it is possible to install packages or programs from the terminal .

One of these functions that Ubuntu offers you is to be able to divide and join files easily using the tools that the Unix program gives you . This will allow you certain configurations and tools to be able to manage your files if you require it using the Split and Cat tools.

Don’t you know how to use these tools? Don’t worry, we love to help anyone who needs to know how things are done so keep reading this article.

We will show you with a simple method how to join and divide files in Ubuntu using the tools that Unix provides, since you were that in a couple of minutes you will know how to use and some characteristics of Unix .

What is Split on Unix?

gray scissors cutting file and white background

It is a command program that has been a great tool for operating systems such as Unix since it allows you to divide a file into other files of a smaller size. In case you can’t find your file you can try searching the files with command .

It performs this type of division of a code file using an extension found in the program to be able to manage the size of the divided files.

In this way, Split allows you to see the scope and detailed characteristics of each partition in a more orderly way. That is why it is named Split because translated from English it means to leave.

It is capable of generating up to files of up to 1000 lines. And for example, the output files are named by adding aa, ab, ac, and so on. And as for the output files, names are used by appending x, such as xaa, xab, and so on.

If used as input file – they can be read from standard input. If you want to go deeper into the features of Split, you can use Man Split to get a better look at the details. In case you want to rejoin the files, then the Cat command kicks in.

What is the Cat Command System?

unix cat command box selection on green black background

The name of this command system is derived from the word concatenate, which translated into Spanish is concatenar, which basically means to join. In other words, in a nutshell, this system will allow you to join the files and display them very easily. Which will allow you to rejoin the files that you have divided with Split.

This program will write to the standard output everything that the files contain, organizing them in the same order that they were given and it will print the files on standard output.

Already having the basic knowledge of what these systems are that will be used in the process, let’s see the steps to follow to divide and join Ubuntu files.

What are the steps to split and join files with Split and Cat?

split black letters white background

Once you are quite clear about the operation of the Split and Cat command programs , it will be much easier for you to divide and join files on your Linux system. Let’s start with the procedure:

If you want to divide a file called test.7z that is 500 Mb in size into several 100 Mb files, then you must type the following command:

  • $ split -b 100m tes.7z divided

When you do, you will see how it returns the 100 Mb files that are derived from the original file. The name it will have will be dividedaa, dividedab and so on.

If the file you added has the –d parameter then the file names will be different since it would use numbers, for example it will have names like divided01, divided02 and so on. And the command you will use is:

  • $ split -b -d 100m tes.7z divided

You will already have your files divided, but if you want to rejoin them, you simply have to execute the following command in the location of the files:

  •  $ cat split *> testUnido.7z

And so, by following these steps, which are quite simple and very easy to follow, you will be able to divide and join files in Linux.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button