⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 327-329.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Special Edition Using Linux, Fourth Edition:Managing Files and Directories</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0789717468//-->

<!--TITLE=Special Edition Using Linux, Fourth Edition//-->

<!--AUTHOR=Jack Tackett//-->

<!--AUTHOR=Jr.//-->

<!--AUTHOR=Steve Burnett//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Que//-->

<!--CHAPTER=17//-->

<!--PAGES=327-329//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="325-327.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="329-331.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H4 ALIGN="LEFT"><A NAME="Heading12"></A><FONT COLOR="#000077">Viewing Files in Other Forms</FONT></H4>

<P>Other commands display the contents of files in different forms. For example, if you want to look at the contents of a binary file, display it with the <TT>od</TT> command, which stands for <I>octal dump</I>. The <TT>od</TT> command displays a file in octal notation, or base 8. By using various flags, <TT>od</TT> can display a file in decimal, ASCII, or hexadecimal (base 16).</P>



<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">

<TR><TD><FONT SIZE="+1"><B>Octal, Decimal, and Hexadecimal Notation</B></FONT>

<P>Representing binary data is an intriguing problem. If the binary data represents ASCII, you have no problem displaying it (ASCII is, after all, what you expect when you look at most files). If the file is a program, however, the data most likely can&#146;t be represented as ASCII characters. In that case, you have to display it in some numerical form.

</P>

<P>The early minicomputers used 12-bit words. Today, of course, the computer world has settled on the 8-bit byte as the standard unit of memory. Although you can represent data in the familiar decimal (base 10) system, the question becomes what to display&#151;a byte, a word, or 32 bits? Displaying a given number of bits compactly requires that base 2 be raised to the required number of bits. With the old 12-bit systems, you could represent all 12 bits with four numbers (represented by 2<SUP>3</SUP>, which was the octal or base 8 format). Because early UNIX systems ran on these kinds of minicomputers, much of the UNIX&#151;and, thus, Linux&#151;notation is in octal. Any byte can be represented by a three-digit octal code that looks like this (this example represents the decimal value of 8):</P>

<!-- CODE SNIP //-->

<PRE>

\010

</PRE>

<!-- END CODE SNIP //-->

<P>Because the world has settled on an 8-bit byte, octal is no longer an efficient way to represent data. Hexadecimal (base 16 or 2<SUP>4</SUP> ) is a better way. An 8-bit byte can be represented by two hexadecimal digits; a byte whose decimal value is 10 is represented as 0A in hexadecimal.</P>

</TABLE>



<P>The <TT>od</TT> command lets you choose how to display binary data. The general form of the command is one of the following:</P>

<!-- CODE SNIP //-->

<PRE>

od [<I>option</I>]&#133; [<I>file</I>]&#133;

</PRE>

<!-- END CODE SNIP //-->

<P>or

</P>

<!-- CODE SNIP //-->

<PRE>

od &#151;traditional [<I>file</I>] [[&#43;]<I>offset</I> [[&#43;]<I>label</I>]]

</PRE>

<!-- END CODE SNIP //-->

<P>Table 17.3 summarizes the flags you can use with <TT>od</TT>.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 17.3</B> The <TT>od</TT> Command Flags

<TR>

<TH COLSPAN="3"><HR>

<TR>

<TH WIDTH="20%" ALIGN="LEFT">Short Flag

<TH WIDTH="35%" ALIGN="LEFT">Full Flag

<TH WIDTH="45%" ALIGN="LEFT">Description

<TR>

<TD COLSPAN="3"><HR>

<TR>

<TD VALIGN="TOP"><TT>-A</TT>

<TD VALIGN="TOP"><TT>--address-radix=<I>radix</I></TT>

<TD>Determines how file offsets are printed

<TR>

<TD VALIGN="TOP"><TT>-N</TT>

<TD VALIGN="TOP"><TT>--read-bytes=<I>bytes</I></TT>

<TD>Limits dump to <I>bytes</I> input bytes per file

<TR>

<TD VALIGN="TOP"><TT>-j</TT>

<TD VALIGN="TOP"><TT>--skip-bytes=<I>bytes</I></TT>

<TD>Skips <I>bytes</I> input bytes first on each file

<TR>

<TD VALIGN="TOP"><TT>-s</TT>

<TD VALIGN="TOP"><TT>--strings[=<I>bytes</I>]</TT>

<TD>Outputs strings of at least <I>bytes</I> graphic characters

<TR>

<TD><TT>-t</TT>

<TD><TT>--format=<I>type</I></TT>

<TD>Selects output format or formats

<TR>

<TD VALIGN="TOP"><TT>-v</TT>

<TD VALIGN="TOP"><TT>--output-duplicates</TT>

<TD>Prevents use of * to mark line suppression

<TR>

<TD><TT>-w</TT>

<TD><TT>--width[=<I>bytes</I>]</TT>

<TD>Outputs <I>bytes</I> bytes per output line

<TR>

<TD>

<TD VALIGN="TOP"><TT>--traditional</TT>

<TD>Accepts arguments in pre-POSIX form

<TR>

<TD>

<TD><TT>--help</TT>

<TD>Displays this help and exits

<TR>

<TD>

<TD VALIGN="TOP"><TT>--version</TT>

<TD>Outputs version information and exits

<TR>

<TD COLSPAN="3"><HR>

</TABLE>

<P>The pre-POSIX format specifications in Table 17.4 may be intermixed with the commands in Table 17.3, in which case their effects accumulate.

</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 17.4</B> Pre-POSIX Format Specifications for <TT>od</TT>

<TR>

<TH COLSPAN="3"><HR>

<TR>

<TH WIDTH="20%" ALIGN="LEFT">Short Flag

<TH WIDTH="30%" ALIGN="LEFT">POSIX Equivalent

<TH WIDTH="50%" ALIGN="LEFT">Description

<TR>

<TD COLSPAN="3"><HR>

<TR>

<TD><TT>-a</TT>

<TD><TT>-t a</TT>

<TD>Selects named characters

<TR>

<TD><TT>-b</TT>

<TD><TT>-t oC</TT>

<TD>Selects octal bytes

<TR>

<TD><TT>-c</TT>

<TD><TT>-t c</TT>

<TD>Selects ASCII characters or backslash escapes

<TR>

<TD><TT>-d</TT>

<TD><TT>-t u2</TT>

<TD>Selects unsigned decimal shorts

<TR>

<TD><TT>-f</TT>

<TD><TT>-t fF</TT>

<TD>Selects floats

<TR>

<TD><TT>-h</TT>

<TD><TT>-t x2</TT>

<TD>Selects hexadecimal shorts

<TR>

<TD><TT>-I</TT>

<TD><TT>-t d2</TT>

<TD>Selects decimal shorts

<TR>

<TD><TT>-l</TT>

<TD><TT>-t d4</TT>

<TD>Selects decimal longs

<TR>

<TD><TT>-o</TT>

<TD><TT>-t o2</TT>

<TD>Selects octal shorts

<TR>

<TD><TT>-x</TT>

<TD><TT>-t x2</TT>

<TD>Selects hexadecimal shorts

<TR>

<TD COLSPAN="3"><HR>

</TABLE>

<P>For older syntax (second-call format), <TT><I>offset</I></TT> means <TT>-j <I>offset.label</I></TT> is the pseudoaddress at first byte printed, incremented when the dump is progressing. For <TT><I>offset</I></TT> and <TT><I>label</I></TT>, a <TT>0x</TT> or <TT>0X</TT> prefix indicates hexadecimal. Suffixes may be . (dot) for octal and may be multiplied by 512. The <TT><I>type</I></TT> parameter is made up of one or more of the specifications listed in Table 17.5.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 17.5</B> Type Parameters

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="20%" ALIGN="LEFT">Parameter

<TH WIDTH="80%" ALIGN="LEFT">Description

<TR>

<TD COLSPAN="2"><HR>

<TR>

<TD><TT>a</TT>

<TD>Named character

<TR>

<TD><TT>c</TT>

<TD>ASCII character or backslash escape

<TR>

<TD><TT>d[<I>size</I>]</TT>

<TD>Signed decimal, <I>size</I> bytes per integer

<TR>

<TD><TT>f[<I>size</I>]</TT>

<TD>Floating point, <I>size</I> bytes per integer

<TR>

<TD><TT>o[<I>size</I>]</TT>

<TD>Octal, <I>size</I> bytes per integer

<TR>

<TD><TT>u[<I>size</I>]</TT>

<TD>Unsigned decimal, <I>size</I> bytes per integer

<TR>

<TD><TT>x[<I>size</I>]</TT>

<TD>Hexadecimal, <I>size</I> bytes per integer

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="325-327.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="329-331.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -