Results 1 to 4 of 4
I've a file with which contains the dump of all the members of a structure in hexadecimal format. where each line contains 4 bytes followed by a newline. Now I ...
- 10-24-2011 #1
hexdump to ASCII
I've a file with which contains the dump of all the members of a structure in hexadecimal format. where each line contains 4 bytes followed by a newline. Now I want to convert this HEX dump to
ASCII. I've tried hexdump(1M) to achieve this but haven't been successful so far.
I'm invoking hexdump as:
[root@localhost]# hexdump -e ' "%s" ' mydump
hexdump: %s requires a precision or a byte count.
<snip from man hexdump>
"A format string contains any number of format units, separated by whitespace. A format unit contains up to three items: an iteration count, a byte count, and a format."
"A byte count or field precision is required for each ‘‘s’’ conversion character"
<snip from man hexdump>
I'm not sure how to provide this precision value.
-Amit
- 10-25-2011 #2Just Joined!
- Join Date
- Jul 2008
- Posts
- 81
- 10-25-2011 #3
Unfortunately I can't share the dump as the code is for internal purpose only. Now I've converted the hex dump as one byte followed by a newline. so it looks something like:
656e6f4e < - --- 1 byte
00000000 < ---- 1 byte
So what change should i do in the command below ?
# hexdump -e '"%2.2s\n"' mydump
- 10-25-2011 #4Just Joined!
- Join Date
- Jul 2008
- Posts
- 81
I think we are getting somewhere, although your understanding of "byte" is different from everybody else's.
It is not necessary to share the whole of your dump, only a few lines to indicate what you have and what you want.
I think I deduce that you want "656e6f4e" to be translated to "enoN" as those are the ASCII characters that correspond to the given two-digit hex codes. Maybe two or three more samples would be good.
Perhaps you are doing the wrong thing when producing the original dump, as it should not be necessary to convert binary data to two-digit hex, and then re-convert to ASCII.


Reply With Quote

