如何更改`hexdump`中打印的列数?

Ily*_*gin 8 bash hexdump

如何更改hexdump默认16(到21)中打印的列数?

或者我在哪里可以找到更改默认格式字符串的地方hexdump,以便修改在那里使用的数字?

gni*_*urf 8

似乎获得了默认格式:

hexdump -e '"%07.7_Ax\n"' -e '"%07.7_ax " 8/2 "%04x " "\n"'
Run Code Online (Sandbox Code Playgroud)

来自man hexdump:

 Implement the -x option:

       "%07.7_Ax\n"
       "%07.7_ax  " 8/2 "%04x " "\n"
Run Code Online (Sandbox Code Playgroud)

如果你想了解它hexdump的格式,你将不得不阅读手册,但这里只是简单介绍以前的格式:

  • 第一部分%07.7_Ax\n是显示仅包含偏移量的最后一行的部分.根据手册:

     _a[dox]     Display the input offset, cumulative across input files, of the
                 next byte to be displayed.  The appended characters d, o, and x
                 specify the display base as decimal, octal or hexadecimal
                 respectively.
    
     _A[dox]     Identical to the _a conversion string except that it is only
                 performed once, when all of the input data has been processed.
    
    Run Code Online (Sandbox Code Playgroud)
  • 对于第二个:我们现在理解这个"%07.7_ax "部分.所述8/2装置8次迭代和2个字节用于以下,即,"%04x ".最后,在这之后,我们有一个新行:"\n".

我不太确定你想要21个字节,也许这样做:

hexdump -e '"%07.7_Ax\n"' -e '"%07.7_ax " 21/1 "%02x " "\n"'
Run Code Online (Sandbox Code Playgroud)

如果需要,你知道如何摆脱偏移量:

hexdump -e '21/1 "%02x " "\n"'
Run Code Online (Sandbox Code Playgroud)