How can I copy several binary files into one file on a Linux system?

BashBinaryCopy

Bash Problem Overview


I need to copy the content of a folder which contains binary files to one binary file in another directory.

In Windows I can just use:

copy file1 + file2 targetfile /B 

I couldn't find something similar for Linux (I saw an approach with cat, but I'm unsure if this really works for binary files).

Bash Solutions


Solution 1 - Bash

Unix has no distinction between text and binary files, which is why you can just cat them together:

cat file1 file2 > target_file

Solution 2 - Bash

cat is a very useful utility that will output the content of one or more files to standard output. That can be redirected with shell-funcionality into a file. It will work with binary or ascii files. In some programming languages that do not use linking, cat is used to merge binary files into a single executable file.

cat file1 file2 > target_file

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAhatiusView Question on Stackoverflow
Solution 1 - BashgeekosaurView Answer on Stackoverflow
Solution 2 - BashchorobaView Answer on Stackoverflow