uTools-Manuals/docs/linux/hexdump.html
2019-04-21 11:50:48 +08:00

34 lines
2.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="hexdump">hexdump</h1>
<p>显示文件十六进制格式</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>hexdump命令</strong> 一般用来查看“二进制”文件的十六进制编码,但实际上它能查看任何文件,而不只限于二进制文件。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">hexdump [选项] [文件]...</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-n length 只格式化输入文件的前length个字节。
-C 输出规范的十六进制和ASCII码。
-b 单字节八进制显示。
-c 单字节字符显示。
-d 双字节十进制显示。
-o 双字节八进制显示。
-x 双字节十六进制显示。
-s 从偏移量开始输出。
-e 指定格式字符串,格式字符串包含在一对单引号中,格式字符串形如:&#39;a/b &quot;format1&quot; &quot;format2&quot;&#39;</code></pre>
<p>每个格式字符串由三部分组成每个由空格分隔第一个形如a/bb表示对每b个输入字节应用format1格式a表示对每a个输入字节应用format2格式一般a&gt;b且b只能为124另外a可以省略省略则a=1。format1和format2中可以使用类似printf的格式字符串</p>
<pre><code class="language-bash">%02d两位十进制
%03x三位十六进制
%02o两位八进制
%c单个字符等</code></pre>
<p>还有一些特殊的用法:</p>
<pre><code class="language-bash">%_ad标记下一个输出字节的序号用十进制表示。
%_ax标记下一个输出字节的序号用十六进制表示。
%_ao标记下一个输出字节的序号用八进制表示。
%_p对不能以常规字符显示的用 . 代替。</code></pre>
<p>同一行如果要显示多个格式字符串,则可以跟多个<code>-e</code>选项。</p>
<h3 id="实例">实例</h3>
<pre><code class="language-bash">hexdump -e &#39;16/1 &quot;%02X &quot; &quot; | &quot;&#39; -e &#39;16/1 &quot;%_p&quot; &quot;\n&quot;&#39; test
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F | ................
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F | ................
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F | !&quot;#$%&amp;&#39;()*+,-./ </code></pre>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->