How to create a hex dump of file containing only the hex characters without spaces in bash?

前端 未结 6 1347
后悔当初
后悔当初 2020-11-30 17:22

How do I create an unmodified hex dump of a binary file in Linux using bash? The od and hexdump commands both insert spaces in the

6条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 17:49

    Format strings can make hexdump behave exactly as you want it to (no whitespace at all, byte by byte):

    hexdump -ve '1/1 "%.2x"'
    

    1/1 means "each format is applied once and takes one byte", and "%.2x" is the actual format string, like in printf. In this case: 2-character hexadecimal number, leading zeros if shorter.

提交回复
热议问题