Is there an easy way to add an offset to the hex dump generated by xxd ?
i.e instead of
0000: <data>
0004: <data>
0008: <data>
I should get
Offset+0000: <data>
Offset+0004: <data>
Offset+0008: <data>
Is there an easy way to add an offset to the hex dump generated by xxd ?
i.e instead of
0000: <data>
0004: <data>
0008: <data>
I should get
Offset+0000: <data>
Offset+0004: <data>
Offset+0008: <data>
If you can live with AWK here's a proof of concept:
I bet it would be shorter in Perl or Python, but AWK just feels more "script-ish" :-)
Reading your comment below:
makes me believe the only way to do this is parsing the output and modifying it in order to add the desired offset.
I didn't found anything in the docs that would allow this to be done easily, sorry. :(
This is what I am doing now..It works perfectly but its kind of lame approach for just adding an offset :)
xxd
now appears to come with offset support, using-o [offset]
for example:
xxd -o 0x07d20000 file.bin
My version of
xxd
on Gentoo Linux has it, but I dug deeper to help folks on other distros:xxd V1.10 27oct98 by Juergen Weigert
-- Do not use the xxd version -- I have found this source code without the offset support!! So I tracked down where my binary comes from:app-editors/vim-core-7.4.769
-- So apparently, as long as you have a modern VIM installed, you can reap the benefits of the added offset support; at least on Gentoo, but I'm steering you in the right direction.If you find that your distro still ships an older xxd, considering manually compiling a newer VIM that you confirm has offset support.