Re: Generic awk script to write 1/2/4/8/16 bytes at a particular offset on a binary file
- From: vibgyorbits <bkajey@xxxxxxxxx>
- Date: Tue, 05 Jun 2007 19:16:49 -0000
myscr <data> <offset> <filename>
myscr 0050630a 000000B0 /dev/dummy
myscr 0050 000000B0 /dev/dummy
myscr 00 000000B0 /dev/dummy
on /dev/dummy
First time:
000000B0 00000000 00000000 00000000 00000000 |................|
../myscr 0050630aecede455 000000B0 /dev/dummy
000000B0 0050630a ecede455 00000000 00000000 |................|
../myscr 0050630a 000000B8 /dev/dummy
000000B0 0050630a ecede455 0050630a 00000000 |................|
& so on...I din't want to give this eg first post,bcoz i wanted to
give some tries.
thanks!
On Jun 5, 1:51 pm, Vassilis <F.H.Nova...@xxxxxxxxx> wrote:
/ vibgyorbits :
Hi,
i'm trying to write a script that can modify the data on a BINARY file
depending on
the # bytes and offset i give.
Below is the eg:
000000B0 00000000 00000000 00000000 00000000 |................|
Note that i need to convert all the input data into UPPER case.
so my ./test.sh <data> <offset> <location>
./test.sh 2a 00000030 file1
000000B0 2A00000000 00000000 00000000 00000000 |................|
./test.sh 2a4d 00000037 file1
000000B0 2A00000000 00000000 2A4D0000 00000000 |................|
-----------
set -A offset `echo $hexoffset | awk ' {
print "ibase=16\n"toupper($0)
} '| bc 2>/dev/null`
set -A a `echo $data | awk ' {
print "ibase=16\nobase=8\n"toupper($0)
} '| bc 2>/dev/null`
----------
But i'm not been able to write the data on to the offset specified.
Also, note that since this is binary data, has to be written in Octal.
And depending on the
size of the <data> i need to write 1/2/4/8/16 bytes.
Any help will be highly useful
thanks in advance!
Your post seems a bit confusing (to say the least):
In the title you ask an awk way to write at specific offsets.
You also say that you've got a binary file, which you pass it through
od (I guess) and want to convert od output to uppercase. By changing
the output to uppercase doesn't change anything.
Then your write two scripts that, by them selfs, don't make much
sense.
Post some input, tell us what's this binary like/for or set a link to
an example, and then try to specify the least of your requirements.
.
- References:
- Prev by Date: Re: Generic awk script to write 1/2/4/8/16 bytes at a particular offset on a binary file
- Next by Date: Re: Shuffle an array's elements in gawk
- Previous by thread: Re: Generic awk script to write 1/2/4/8/16 bytes at a particular offset on a binary file
- Next by thread: Mersenne twister for (g)awk?
- Index(es):
Relevant Pages
|