【问题标题】:How can I change the number of columns printed by `hexdump`?如何更改 `hexdump` 打印的列数?
【发布时间】:2014-11-01 22:48:28
【问题描述】:

如何将hexdump 打印的列数从默认的 16 更改为 21?

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

【问题讨论】:

  • 你可以试试这个hexdump -e '21/1 "%02x " "\n"'
  • @gniourf_gniourf 它有效!谢谢。
  • 请找到一个包含默认格式信息的答案。

标签: hexdump


【解决方案1】:

似乎默认格式是这样获得的:

hexdump -e '"%07.7_Ax\n"' -e '"%07.7_ax " 8/2 "%04x " "\n"'

来自man hexdump:

 Implement the -x option:

       "%07.7_Ax\n"
       "%07.7_ax  " 8/2 "%04x " "\n"

如果您想了解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.
    
  • 第二个:我们现在了解"%07.7_ax " 部分。 8/2 表示 8 次迭代和以下 2 个字节, 即 "%04x "。最后,在这些之后,我们有一个换行符:"\n"。

我不确定你想要你的 21 个字节。也许这样可以:

hexdump -e '"%07.7_Ax\n"' -e '"%07.7_ax " 21/1 "%02x " "\n"'

如果需要,您知道如何消除偏移:

hexdump -e '21/1 "%02x " "\n"'

【讨论】:

    猜你喜欢
    • 2021-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-11
    • 1970-01-01
    • 2012-06-23
    相关资源
    最近更新 更多