LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Linux utility to combine two or more binary files into a single binary file (http://www.linuxquestions.org/questions/programming-9/linux-utility-to-combine-two-or-more-binary-files-into-a-single-binary-file-878957/)

mageshvan 05-05-2011 05:14 AM

Linux utility to combine two or more binary files into a single binary file
 
Hello,

Is there any Linux utility to combine two or more binary files into a single binary file ?

Thanks

David the H. 05-05-2011 05:24 AM

Care to elaborate a little? The phrase "binary file" can encompass a lot of different things, as does the word "combine".

Tell us exactly what you want to do, and maybe we can suggest ways to do it. A vague question like yours is only going to get vague answers like this.

Sergei Steshenko 05-05-2011 06:19 AM

Quote:

Originally Posted by mageshvan (Post 4347172)
Hello,

Is there any Linux utility to combine two or more binary files into a single binary file ?

Thanks

Code:

cat file1 file2 > file3
- read 'man 1 cat' first.

mageshvan 05-05-2011 06:49 AM

Hello,

Sorry for my vague question.

Let me elaborate it. I found that a linux utility "dd" which can be used to copy or convert the file. I am just wondering if the same can be used for combining the .bin files ?

for example:

dd command can be used to do the following:

dd if=/home/app/ex1.bin of=/opt/ex2.bin


I don;t see any option to do something like...

dd if=/home/app/ex1.bin if=/home/app/ex2.bin of=ex1_ex2.bin

when I tried the above command its taking only ex2.bin and placing in ex1_ex2.bin.

Appreciate if anybody could help me.

Thanks

TobiSGD 05-05-2011 07:19 AM

At first, if you already have files it is simpler to do the copy with the cp command.

But for what you want achieve just follow Sergei Steshenko's advice. In your example:
Code:

cat /home/app/ex1.bin /home/app/ex2.bin > ex1_ex2.bin

mageshvan 05-05-2011 07:29 AM

Hello,

I just tried

cat /home/app/ex1.bin > ex1_ex2.bin


cat =/home/app/ex2.bin >> ex1_ex2.bin

When I did ls -l ex1_ex2.bin size seems to be the sum of ex1.bin + ex2.bin... though I didnt check the contents yet.


Thanks

mageshvan 05-05-2011 07:31 AM

hello,

if I do execute this its crashing........

cat /home/app/ex1.bin /home/app/ex2.bin > ex1_ex2.bin


Thanks,

Sergei Steshenko 05-05-2011 08:06 AM

Quote:

Originally Posted by mageshvan (Post 4347262)
Hello,

Sorry for my vague question.

Let me elaborate it. I found that a linux utility "dd" which can be used to copy or convert the file. I am just wondering if the same can be used for combining the .bin files ?

for example:

dd command can be used to do the following:

dd if=/home/app/ex1.bin of=/opt/ex2.bin


I don;t see any option to do something like...

dd if=/home/app/ex1.bin if=/home/app/ex2.bin of=ex1_ex2.bin

when I tried the above command its taking only ex2.bin and placing in ex1_ex2.bin.

Appreciate if anybody could help me.

Thanks

What is wrong with my suggestion: http://www.linuxquestions.org/questi...7/#post4347231 ?


All times are GMT -5. The time now is 11:18 PM.