| by Arround The Web | No comments

How To Combine Binary Files in Linux

In the Linux binary directory, the files which contain machine code or compiled source data are ‌ known as binary files. The content of binary files is not in a human-readable format, as a specific program only interprets these files. Any program can look for the data to a particular location within the file, so the binary files are not in an externally recognizable format.

You can execute these files in the system, so it is also called executable files. You can use common and single-user mode commands for binary files, such as ls, cd, cp, and cat. So, let’s look at the simple approaches to combining the binary files in Linux.

How To Combine Binary Files in Linux

Combining two or more binary files in Linux is the most straightforward task. You can combine binary files using a single command-line method. Let’s use the “cat” command to join or merge the binaries.

The cat command’s most common use is to print a file’s contents to the standard output stream. It combines the files and prints the result to standard output. Moreover, the cat command allows the user to write some text within the file.

Using the cat command, you can combine binaries using the following command:

cat <filename1>.bin <filename2>.bin <filename3>.bin > <filename4>.bin

Here, we have used the redirection symbol “>” to write the combined output to a file. We combine three binary files into the fourth binary file, or we can say that we put the data of 3 binaries in the 4th.

To combine the binary files, open the terminal and verify the present binary files using the following “cd” command:

cd ~/<directory_name>

ls

You can check the present binaries available in your home directory from the output. For example, we combine the 1st and 2nd binary in the 3rd binary. Use the “cat” command to accomplish this:

cat f1.bin f2.bin f3.bin > f4.bin

After running the previous command, you will not see any output in the terminal. However, when you go to your home directory, you ‌ see that your binary files have been combined.

Conclusion

Binary files contain any unformatted and formatted data in binary format. The system directly uses these files, but users can’t read them. Binaries are more efficient than text files in access speed, store values (using numeric format), memory, etc.

The purpose of this guide was to explain how to combine binary files in Linux. Binary files occupy less space for the same data as compared to text files. Here, we have described how to combine binary files with the help of the cat command.

Share Button

Source: linuxhint.com

Leave a Reply