Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

bash

copy

binary

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).

like image 629
Ahatius Avatar asked Apr 27 '12 08:04

Ahatius


People also ask

How do I combine binary files?

To combine binary files in Power Query Editor, select Content (the first column label) and select Home > Combine Files. Or you can just select the Combine Files icon next to Content.

How do I join two binary files in Linux?

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.

How do I copy a binary file in Linux?

Use the cp command,but you can use the dd command or mv(move)command,when I've used cp it copied all my files in binary and completely porked them,so type" man cp “ in a terminal and learn how to use cp or dd or mv.


2 Answers

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

cat file1 file2 > target_file 
like image 67
geekosaur Avatar answered Sep 20 '22 22:09

geekosaur


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 
like image 43
choroba Avatar answered Sep 21 '22 22:09

choroba