gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 08:55:07 25 4
gpt4 key购买 nike

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

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

最佳答案

默认的格式好像是这样得到的:

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"'

关于hexdump - 如何更改 `hexdump` 打印的列数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26694065/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com