Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hexdump -C but decimal instead of hex

centos 6.5 - running hexdump

$ hexdump -C filecsv
00000000  44 4f 53 2c 20 50 61 74  69 65 6e 74 2c 20 41 63  |DOS, Patient, Ac|
00000010  63 74 20 23 2c 20 4d 52  20 23 2c 20 54 69 6d 65  |ct #, MR #, Time|

Love this format but want hex to be converted to decimal I have spent time looking but cannot find this?

like image 326
Tim OBrien Avatar asked Nov 01 '14 19:11

Tim OBrien


People also ask

What does 0x00 mean in hex?

An all-zero octet.

What is XFF in hex?

Overview. 0xff is a number represented in the hexadecimal numeral system (base 16). It's composed of two F numbers in hex. As we know, F in hex is equivalent to 1111 in the binary numeral system. So, 0xff in binary is 11111111.

What is 0x10 in hexadecimal?

So 0x10 is hexadecimal for 16. And, 0xFF is hexadecimal for 255. The table below counts 0 to 19 in hexadecimal: Decimal. Hexadecimal.

How many bytes is a Hexdump?

Example dumping a partition table using hexdump. By coincidence the partition table entry length and the default line length of hexdump are 16 bytes so each line is a complete partition table entry.


1 Answers

hexdump supports specifying a format string via the -e command-line option, and it seems to be pretty flexible.

Example:

$ hexdump -C b.c
00000000  23 69 6e 63 6c 75 64 65  20 3c 73 74 64 69 6f 2e  |#include <stdio.|
00000010  68 3e 0a 69 6e 74 20 6d  61 69 6e 28 29 7b 0a 20  |h>.int main(){. |
00000020  20 70 72 69 6e 74 66 28  22 68 65 6c 6c 6f 20 77  | printf("hello w|
00000030  6f 72 6c 64 5c 6e 22 29  3b 0a 20 20 72 65 74 75  |orld\n");.  retu|
00000040  72 6e 20 30 3b 0a 7d 0a                           |rn 0;.}.|
00000048
$ hexdump -e'"%07.8_ax  " 8/1 "%02x " "  " 8/1 "%02x " "  |"' -e'16/1  "%_p"  "|\n"' b.c
00000000  23 69 6e 63 6c 75 64 65  20 3c 73 74 64 69 6f 2e  |#include <stdio.|
00000010  68 3e 0a 69 6e 74 20 6d  61 69 6e 28 29 7b 0a 20  |h>.int main(){. |
00000020  20 70 72 69 6e 74 66 28  22 68 65 6c 6c 6f 20 77  | printf("hello w|
00000030  6f 72 6c 64 5c 6e 22 29  3b 0a 20 20 72 65 74 75  |orld\n");.  retu|
00000040  72 6e 20 30 3b 0a 7d 0a                           |rn 0;.}.|
$ hexdump -e'"%07.8_ad  " 8/1 "%03d " "  " 8/1 "%03d " "  |"' -e'16/1  "%_p"  "|\n"' b.c
00000000  035 105 110 099 108 117 100 101  032 060 115 116 100 105 111 046  |#include <stdio.|
00000016  104 062 010 105 110 116 032 109  097 105 110 040 041 123 010 032  |h>.int main(){. |
00000032  032 112 114 105 110 116 102 040  034 104 101 108 108 111 032 119  | printf("hello w|
00000048  111 114 108 100 092 110 034 041  059 010 032 032 114 101 116 117  |orld\n");.  retu|
00000064  114 110 032 048 059 010 125 010                                   |rn 0;.}.|

Not sure about how to reproduce that last line produced by -C.

See here for more details.

like image 194
Vlad Avatar answered Sep 30 '22 20:09

Vlad