Every time I go to use hexdump I find myself stumbling over it's bizarre argument format and ineffectual manual. Because I look at binary files often I decided to work up this page more for myself than anyone else.
Here is a sample usage of hexdump:
cat file | hexdump -v -e '"\\\x" 1/1 "%02x" " "'
And here is some sample output from it:
\x97\x6d\xea\xd1\x21\x02\x12\x80\x01\x9d...
The -v argument is needed to not print duplicate chars as a *. The -e argument has 5 parts separated by whitespace. I'm not sure how multiple format entries interact.
Print an "x" to start, take 1 item / 1 byte, print it as a 2 digit 0 prefixed hex value ("%02X"), and end with a space.
echo "hello there" | hexdump -v -e '"x" 1/1 "%02X" " "'
Outputs something like:
x68 x65 x6C x6C x6F x20 x74 x68 x65 x72 x65 x0A
Print an "[" to start, take 2 items / each 1 byte, print them as a 3 digit 0 prefixed octal value followed by a space ("%03o "), and end with "]\n".
echo "hello there" | hexdump -v -e '"[" 2/1 "%03o " "]\n"'
Outputs something like:
[150 145] [154 154] [157 040] [164 150] [145 162] [145 012]
NOTE: the trailing space in "%03o " format will not be printed at the end of each interation.
Free Spam Protection Android ORM Simple Java Zip JMX using HTTP Great Eggnog Recipe