hexdump可以用于以16进制格式显示文件内容
帮助信息如下:
hexdump --help
- root@hehe:/sys/bus/i2c/devices/1-0060/of_node# hexdump --help
-
- Usage:
- hexdump [options] <file>...
-
- Display file contents in hexadecimal, decimal, octal, or ascii.
-
- Options:
- -b, --one-byte-octal one-byte octal display
- -c, --one-byte-char one-byte character display
- -C, --canonical canonical hex+ASCII display
- -d, --two-bytes-decimal two-byte decimal display
- -o, --two-bytes-octal two-byte octal display
- -x, --two-bytes-hex two-byte hexadecimal display
- -L, --color[=<mode>] interpret color formatting specifiers
- colors are enabled by default
- -e, --format <format> format string to be used for displaying data
- -f, --format-file <file> file that contains format strings
- -n, --length <length> interpret only length bytes of input
- -s, --skip <offset> skip offset bytes from the beginning
- -v, --no-squeezing output identical lines
-
- -h, --help display this help and exit
- -V, --version output version information and exit
-
- For more details see hexdump(1).
- root@hehe:/sys/bus/i2c/devices/1-0060/of_node#
读取一个文件的值:文件mclk是设备中的一个属性,其值为24 000 000就是24Mhz。十六进制是0x016e 3600。使用hexdump 读值如下所示,显然,这样读出来的值可读性很差。
- root@hehe:/sys/bus/i2c/devices/1-0060/of_node# hexdump mclk
- 0000000 6e01 0036
- 0000004
那就想办法,加个参数吧
参数-b
- # hexdump -b mclk
- 0000000 001 156 066 000
- 0000004
参数-c
- # hexdump -c mclk
- 0000000 001 n 6 \0
- 0000004
参数-d
- # hexdump -d mclk
- 0000000 28161 00054
- 0000004
参数-C
很显然,这个值是可以接受的。
- # hexdump -C mclk
- 00000000 01 6e 36 00 |.n6.|
- 00000004
参数-o
- # hexdump -o mclk
- 0000000 067001 000066
- 0000004
参数-x
这个和不加参数时,几乎一样
- # hexdump -x mclk
- 0000000 6e01 0036
- 0000004
参数-e
这个有点复杂啊,得多写两个例子
- # hexdump -e '/1 "%8X"' mclk
- 1 6E 36 0
- # hexdump -e '/2 "%8X"' mclk
- 6E01 36
- # hexdump -e '/4 "%8X"' mclk
- 366E01
(⊙o⊙)…没有找到我想要的结果。