LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-05-2011, 05:14 AM   #1
mageshvan
LQ Newbie
 
Registered: Aug 2007
Posts: 11

Rep: Reputation: 0
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
 
Old 05-05-2011, 05:24 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
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.
 
Old 05-05-2011, 06:19 AM   #3
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by mageshvan View Post
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.
 
Old 05-05-2011, 06:49 AM   #4
mageshvan
LQ Newbie
 
Registered: Aug 2007
Posts: 11

Original Poster
Rep: Reputation: 0
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
 
Old 05-05-2011, 07:19 AM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047
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
 
Old 05-05-2011, 07:29 AM   #6
mageshvan
LQ Newbie
 
Registered: Aug 2007
Posts: 11

Original Poster
Rep: Reputation: 0
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
 
Old 05-05-2011, 07:31 AM   #7
mageshvan
LQ Newbie
 
Registered: Aug 2007
Posts: 11

Original Poster
Rep: Reputation: 0
hello,

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

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


Thanks,
 
Old 05-05-2011, 08:06 AM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by mageshvan View Post
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 ?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] C program that will take as input a single binary file containing captured Ethernet d kokocs Programming 8 10-11-2010 09:07 PM
Help: Opening GenICs binary file, writing to binary file for GADGET-2 (in C) parallax147 Programming 0 10-05-2010 11:06 AM
Executing multiple instances of a binary file from a single script? j_65_uk Linux - Newbie 3 07-02-2009 04:56 PM
C binary files: Deleting part of the file and resizing xemous Programming 8 03-27-2008 08:49 AM
Command to combine several files as a single file, etc. satimis *BSD 3 06-10-2004 03:59 AM


All times are GMT -5. The time now is 09:44 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration