我该如何将hexdump
默认打印的列数从16更改为21?
或者在哪里可以找到更改hexdump
中使用的默认格式字符串的地方,以便修改其中使用的数字?
我该如何将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次迭代,每次需要读取两个字节,也就是"%04x "
。最后,在所有这些之后,我们有一个换行符:"\n"
。
我不太确定您希望的21字节是什么。也许这样就可以了:
hexdump -e '"%07.7_Ax\n"' -e '"%07.7_ax " 21/1 "%02x " "\n"'
如果需要,您知道如何消除偏移:
hexdump -e '21/1 "%02x " "\n"'
hexdump -e '21/1 "%02x " "\n"'
。 - gniourf_gniourf