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

📄 277-282.html

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

<HEAD>

<TITLE>Linux in Plain English:Linux Commands Organized by Group</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=1558285423//-->

<!--TITLE=Linux in Plain English//-->

<!--AUTHOR=Patrick Volkerding//-->

<!--AUTHOR=Kevin Reichard//-->

<!--PUBLISHER=IDG Books Worldwide, Inc.//-->

<!--IMPRINT=M & T Books//-->

<!--CHAPTER=5//-->

<!--PAGES=277-282//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="268-277.html">Previous</A></TD>

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

<TD><A HREF="283-286.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P><FONT SIZE="+1"><B>cat......<TT>Concatenate Files</TT></B></FONT></P>

<P><B>cat</B> <I>option(s) files</I></P>

<P><FONT SIZE="+1"><B><I>PURPOSE</I></B></FONT></P>

<P>The <B>cat</B> command is the most useful command in the Linux operating system, thanks to the many (mostly) mundane functions that it performs. On a basic level, it reads a file and prints it to standard output (usually the screen, unless standard output has been piped to another command or file). The <B>cat</B> command can also be combined with the &gt; operator to combine files into a single file, as well as the &gt;&gt; operator to append files to an existing file. Finally, the <B>cat</B> command can create a new text file when combined with the name of a new file.</P>

<P><FONT SIZE="+1"><B><I>OPTIONS</I></B></FONT></P>

<TABLE WIDTH="100%">

<TR>

<TD WIDTH="35%" VALIGN="TOP"><B>-A</B> or <B>--show-all</B>

<TD WIDTH="65%">Prints nonprinting and control characters, except for linefeeds and tabs; places a dollar sign at the end of each line; and prints tabs as <B>^I</B>. (The same as <B>-vET</B>.)

<TR>

<TD VALIGN="TOP"><B>-e</B>, <B>-E</B>, or <B>--show-ends</B>

<TD>Prints a dollar sign ($) at the end of each line.

<TR>

<TD VALIGN="TOP"><B>-n</B>

<TD>Numbers the lines, beginning with 1 at the beginning of the first line.

<TR>

<TD><B>-s</B>

<TD>Squeezes out blank lines.

<TR>

<TD><B>-t</B>

<TD>Prints each tab as <B>^I</B> and form feeds as <B>^L</B>.

<TR>

<TD><B>-T</B> or <B>--show-tabs</B>

<TD>Prints each tab as <B>^I</B>.

<TR>

<TD VALIGN="TOP"><B>-u</B>

<TD>Doesn&#146;t do anything; exists for compatibility with other UNIX scripts.

<TR>

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

<TD>Shows nonprinting and control characters, except for linefeeds and tabs.

</TABLE>

<P><FONT SIZE="+1"><B><I>EXAMPLES</I></B></FONT></P>

<!-- CODE SNIP //-->

<PRE>

$ cat report

</PRE>

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

<P>This displays the file named <B>report</B>.</P>

<!-- CODE SNIP //-->

<PRE>

$ cat report report2

</PRE>

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

<P>This displays the file <B>report</B>, followed immediately by the file <B>report2</B>.</P>

<!-- CODE SNIP //-->

<PRE>

$ cat report report2 &gt; report3

</PRE>

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

<P>This combines <B>report</B> and <B>report2</B> into a new file called <B>report3</B>. The combination occurs in the order that the files are specified on the command line.</P>

<!-- CODE SNIP //-->

<PRE>

$ cat report &gt; report2

</PRE>

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

<P>This copies the contents of the file <B>report</B> into a new file named <B>report2</B>. The old file <B>report</B> remains unchanged.</P>

<!-- CODE SNIP //-->

<PRE>

$ cat &gt; report

</PRE>

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

<P>This creates a new file named <B>report</B> and sends your subsequent keyboard input into the file. You can end the input by pressing <B>Ctrl-D</B>.</P>

<!-- CODE SNIP //-->

<PRE>

$ cat report &gt;&gt; report2

</PRE>

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

<P>This places the contents of the file <B>report</B> at the end of the existing file <B>report2</B>.</P>

<!-- CODE SNIP //-->

<PRE>

$ cat - &gt;&gt; report

</PRE>

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

<P>This places keyboard input at the end of the existing file <B>report2</B>. You can end the input by pressing <B>Ctrl-D</B>.</P>

<P><FONT SIZE="+1"><B><I>RELATED COMMANDS</I></B></FONT></P>

<DL>

<DD><B>cp</B>

<DD><B>more</B>

<DD><B>page</B>

</DL>

<P><FONT SIZE="+1"><B>cmp......<TT>Compare Files</TT></B></FONT></P>

<P><B>cmp</B> <I>option(s) filename1 filename2</I></P>

<P><FONT SIZE="+1"><B><I>PURPOSE</I></B></FONT></P>

<P>The <B>cmp</B> command compares the contents of two files. If there&#146;s no difference between the files, there&#146;s no return from <B>cmp</B>. If the files are different, then <B>cmp</B> returns the line number and byte position of the first difference. This command can be used with binary files as well as text files, as opposed to text-only tools like <B>diff</B>.</P>

<P><FONT SIZE="+1"><B><I>OPTIONS</I></B></FONT></P>

<TABLE WIDTH="100%">

<TR>

<TD WIDTH="20%"><B>-c</B>

<TD COLSPAN="2">Prints the differing bytes as characters.

<TR>

<TD><B>-i <I>num</I></B>

<TD COLSPAN="2">Ignores the first <I>num</I> of bytes in the files.

<TR>

<TD VALIGN="TOP"><B>-l</B>

<TD COLSPAN="2">Displays the byte position and differing characters for all differences within the files.

<TR>

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

<TD COLSPAN="2">Works in silent mode, returning only the exit codes and not any instances of differences. The exit code is one of the following:

<TR>

<TD>

<TD WIDTH="15%"><B>0</B>

<TD WIDTH="65%">Files are identical.

<TR>

<TD>

<TD><B>1</B>

<TD>Files are different.

<TR>

<TD>

<TD><B>2</B>

<TD>One of the files cannot be read.

</TABLE>

<P><FONT SIZE="+1"><B><I>EXAMPLE</I></B></FONT></P>

<!-- CODE SNIP //-->

<PRE>

$ cmp report memo

report memo differ: char 12, line 1

</PRE>

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

<P><FONT SIZE="+1"><B><I>RELATED COMMANDS</I></B></FONT></P>

<DL>

<DD><B>comm</B>

<DD><B>diff</B>

<DD><B>sdiff</B>

</DL>

<P><FONT SIZE="+1"><B>colrm......<TT>Column Remove</TT></B></FONT></P>

<P><B>colrm</B> <I>start stop file</I></P>

<P><FONT SIZE="+1"><B><I>PURPOSE</I></B></FONT></P>

<P>The <B>colrm</B> command removes columns from a specified file, but there must be only one character in a line, separated by spaces.</P>

<P><FONT SIZE="+1"><B>column......<TT>Column Formatting</TT></B></FONT></P>

<P><B>column</B> <I>option(s) file</I></P>

<P><FONT SIZE="+1"><B><I>PURPOSE</I></B></FONT></P>

<P>The <B>column</B> command formats input into columns, whether from a <I>file</I> or from standard input.</P>

<P><FONT SIZE="+1"><B><I>OPTIONS</I></B></FONT></P>

<TABLE WIDTH="100%">

<TR>

<TD WIDTH="20%"><B>-c <I>num</I></B>

<TD WIDTH="80%">Sets the number of columns as <I>num</I>.

<TR>

<TD VALIGN="TOP"><B>-s <I>char</I></B>

<TD>Sets <I>char</I> as the column delimiter. Must be used in conjunction with <B>-t</B>.

<TR>

<TD VALIGN="TOP"><B>-t</B>

<TD>Formats input as a table and not as a column. The default is to format with spaces, unless an alternative has been set with <B>-s</B>.

<TR>

<TD><B>-x</B>

<TD>Fills characters before filling the rows.

</TABLE>

<P><FONT SIZE="+1"><B>comm......<TT>Compare Files</TT></B></FONT></P>

<P><B>comm</B> <I>option(s) file1 file2</I></P>

<P><FONT SIZE="+1"><B><I>PURPOSE</I></B></FONT></P>

<P>The <B>comm</B> command compares the contents of two files that have already been sorted with the <B>sort</B> command. The output is sorted into three columns:</P>

<TABLE WIDTH="100%"><TR>

<TD WIDTH="25%"><B>Lines in</B> <I>file1</I>

<TD WIDTH="25%"><B>Lines in</B> <I>file2</I>

<TD WIDTH="50%"><B>Lines in both files</B>

</TABLE>

<P>This command is similar to the <B>diff</B> and <B>uniq</B> commands, except that <B>comm</B> can be used with two sorted files to seek out duplicate or unique lines.</P>

<P><FONT SIZE="+1"><B><I>OPTIONS</I></B></FONT></P>

<TABLE WIDTH="100%">

<TR>

<TD WIDTH="20%"><B>-1</B>

<TD WIDTH="80%">Suppresses the printing of the first column.

<TR>

<TD><B>-2</B>

<TD>Suppresses the printing of the second column.

<TR>

<TD><B>-3</B>

<TD>Suppresses the printing of the third column.

<TR>

<TD><B>-12</B>

<TD>Suppresses the printing of the first and second columns.

<TR>

<TD><B>-13</B>

<TD>Suppresses the printing of the first and third columns.

<TR>

<TD><B>-23</B>

<TD>Suppresses the printing of the second and third columns.

</TABLE>

<P><FONT SIZE="+1"><B><I>RELATED COMMANDS</I></B></FONT></P>

<DL>

<DD><B>cmp</B>

<DD><B>diff</B>

<DD><B>sdiff</B>

<DD><B>sort</B>

</DL>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="268-277.html">Previous</A></TD>

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

<TD><A HREF="283-286.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 + -