what is iteration count and byte count in hexdump?

萝らか妹 提交于 2019-12-12 03:38:22

问题


It was really confusing to deal with hexdump command in linux. Basically I am trying to get the output from the /proc/device-tree. I tried to use the hexdump but ended up with confusion. My dts contains

vvn = <0 0 2 2 0 0>;

I got a proc node under /proc/device-tree.

I tried the following command.

hexdump -v  -e '4/1 "%x" " "' vvn ; echo
0000 0000 0002 0002 0000 0000

hexdump -v  -e '1/4 "%x" " "' vvn ; echo
0 0 2000000 2000000 0 0 

hexdump -v  -e '4/1 "%x "' vvn ; echo
0 0 0 00 0 0 00 0 0 20 0 0 20 0 0 00 0 0 0

I got different output, I thought all will produce the same output. Can anyone please explain me how to use the iterationcount and bytecount of the hexdump and what it's for and How to use the format too?


回答1:


Iteration count controls how may times the format will be repeated.

Byte count indicates how many byte will be format for each iteration.

Format string is the same as that of printf.

'4/1 "%x" " "': iteration for 4 times: in each time, format 1 byte with "%x", and when the iteration finished, insert " ".

'1/4 "%x" " "': iteration for 1 time: in each time, format 4 byte with "%x", and when the iteration finished, insert " ". This is equal to '1/4 "%x "'

'4/1 "%x "': iteration for 4 times: in each time, format 1 byte with "%x "; when iteration finished, eats the last space, insert nothing.

I do know why hexdump eats the last space :(.



来源:https://stackoverflow.com/questions/37020333/what-is-iteration-count-and-byte-count-in-hexdump

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!