Find the answer to your Linux question:
Results 1 to 5 of 5
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! amit4g's Avatar
    Join Date
    Feb 2007
    Location
    Bangalore,India
    Posts
    63

    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

  2. #2
    Just Joined!
    Join Date
    Jul 2008
    Posts
    93
    Quote Originally Posted by amit4g View Post
    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.
    Try something like this:
    Code:
     
    hexdump -e '"%2.2s\n"' mydump
    I am not quite sure this will do what you want. It would be helpful to have a sample of the original data, together with the corresponding desired output.

  3. #3
    Just Joined! amit4g's Avatar
    Join Date
    Feb 2007
    Location
    Bangalore,India
    Posts
    63
    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

  4. #4
    Just Joined!
    Join Date
    Jul 2008
    Posts
    93
    Quote Originally Posted by amit4g View Post
    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
    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.

  5. #5
    Just Joined!
    Join Date
    Oct 2012
    Posts
    1
    this may do it.
    xxd -a FILENAME

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •