LoginSignup
0
0

More than 3 years have passed since last update.

hexdump

Last updated at Posted at 2020-09-03

必要になって新しいのを作ったら追加していきます。

標準

% hexdump -v hoge.bin
0000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
0000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
0000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
0000030 30 31 32 33 34 35 36 37 38 39 3a               
000003b

アセンブラ用

アドレスなし

% hexdump -v -e '1/1 " db 0x%02x" 15/1 ",0x%02x"' -e '"\n"' hoge.bin               
 db 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f
 db 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f
 db 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f
 db 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x  ,0x  ,0x  ,0x  ,0x  

アドレスあり(コメント)

% hexdump -v -e '";%08_ax" "\n" 1/1 " db 0x%02x" 15/1 ",0x%02x"' -e '"\n"' hoge.bin
;00000000
 db 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f
;00000010
 db 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f
;00000020
 db 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f
;00000030
 db 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x  ,0x  ,0x  ,0x  ,0x  

最後の半端は何とかならないものか?

とある形式(16進数+ASCII)

% hexdump -v -e '"%08_ax : " 8/1 "%02x " "  " 8/1 "%02x "' -e '"   " 16 "%_p" "\n"' hoge.bin 
00000000 : 00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f   ................
00000010 : 10 11 12 13 14 15 16 17  18 19 1a 1b 1c 1d 1e 1f   ................
00000020 : 20 21 22 23 24 25 26 27  28 29 2a 2b 2c 2d 2e 2f    !"#$%&'()*+,-./
00000030 : 30 31 32 33 34 35 36 37  38 39 3a                  0123456789:
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0