LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Combine two or more bin files into another bin file at specific addresses in bash (https://www.linuxquestions.org/questions/programming-9/combine-two-or-more-bin-files-into-another-bin-file-at-specific-addresses-in-bash-4175540218/)

WSRaptor 04-20-2015 09:34 AM

Combine two or more bin files into another bin file at specific addresses in bash
 
I'm looking to create a script that will take two or more bin files as an input and output a new new bin file which has the two files combined at specific addresses (with any blank areas being filled by FF).

For example:

Input these files at these addresses
- file1.bin @ address 0x00010
- file2.bin @ address 0x20000

both files will not fill the entire address range so any empty space is filled with FF.

So the result will be something like this (viewed in HEX):

00000000 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
00000010 0A 05 01 08 00 00 00 00 53 01 BE 00 64 00 64 00
00000020 EB 6C 70 C1 E1 C1 E0 40 00 9E 5B 34 C1 D3 C1 DE
00000030 A5 AE 69 78 24 BE BC BF BB C1 D2 87 6C 13 07 94
00000040 C1 D6 3C 88 C1 DA C1 CC C1 D1 7B 60 3C 32 AB C1
.
.
.
000FFD0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
000FFE0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
000FFF0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
0020000 C3 05 01 08 07 1A 38 12 53 01 BE 00 64 33 64 00
0020010 E9 9F AA C1 FD A0 B3 C1 C2 8B BE 71 24 C1 DC C1
0020020 EB 6C 70 C1 E1 C1 E0 40 00 9E 5B 34 C1 D3 C1 DE
.
.
.

Can anyone help me?

millgates 04-20-2015 02:36 PM

Hello,
is this a homework?
What have you done so far and where are you stuck?
I would start by reading the documentation for the dd program.


All times are GMT -5. The time now is 07:20 PM.