'\" te .\" Copyright (c) 2008, 2013, Oracle and/or its affiliates.All rights reserved. .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation.Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation.In the following statement, the phrase "this text" refers to portions of the system documentation.Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document.The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.This notice shall appear on any product containing this material. .TH cat 1 "2011 年 7 月 25 日" "SunOS 5.11" "用户命令" .SH 名称 cat \- 串联并显示文件。 .SH 用法概要 .LP .nf \fB/usr/bin/cat\fR [\fB-nbsuvet\fR] [\fIfile\fR...] .fi .SH 描述 .sp .LP \fBcat\fR 实用程序可以读取序列中的每个 \fIfile\fR,并将其写入标准输出。因此: .sp .in +2 .nf example% \fBcat file\fR .fi .in -2 .sp .sp .LP 在您的终端列显 \fIfile\fR,并且: .sp .in +2 .nf example% \fBcat file1 file2 >file3\fR .fi .in -2 .sp .sp .LP 串联 \fIfile1\fR 和 \fIfile2\fR,然后将结果写入 \fIfile3\fR。如果未指定输入文件,\fBcat\fR 将从标准输入文件中读取输入。 .SH 选项 .sp .LP \fB/usr/bin/cat\fR 支持以下选项: .sp .ne 2 .mk .na \fB\fB-b\fR\fR .ad .RS 6n .rt 为各个行进行编号(例如 \fB-n\fR),但是忽略空白行的行编号。 .RE .sp .ne 2 .mk .na \fB\fB-n\fR\fR .ad .RS 6n .rt 输出每个行时在前面加上其行编号。 .RE .sp .ne 2 .mk .na \fB\fB-s\fR\fR .ad .RS 6n .rt \fBcat\fR 对于不存在的文件不提供任何提示。 .RE .sp .ne 2 .mk .na \fB\fB-u\fR\fR .ad .RS 6n .rt 输出不会缓冲。 .sp 缺省情况下缓冲输出。 .RE .sp .ne 2 .mk .na \fB\fB-v\fR\fR .ad .RS 6n .rt 不可列显字符(制表符、换行符和换页符除外)以可见的方式列显。ASCII 控制字符(八进制 \fB000\fR - \fB037\fR)列显为 \fB^\fR\fI n\fR,其中 \fIn\fR 是八进制 100 - 137 范围中对应的 ASCII 字符(@、A、B、C、.. .、X、Y、Z、[、\、]、^ 和 _);而 \fBDEL\fR 字符(八进制 \fB0177\fR)列显为 \fB^?\fR。其他不可列显的字符均列显为 \fBM-\fR\fIx\fR,其中 \fIx\fR 是低阶七位指定的 ASCII 字符。 .RE .sp .LP 当配合 \fB-v\fR 选项使用时,可以使用以下选项: .sp .ne 2 .mk .na \fB\fB-e\fR\fR .ad .RS 6n .rt \fB$\fR 字符列显在每行的末尾,换行符之前。 .RE .sp .ne 2 .mk .na \fB\fB-t\fR\fR .ad .RS 6n .rt 制表符列显为 \fB^I\fR,而换页符列显为 \fB^L\fR。 .RE .sp .LP 如果未指定 \fB-v\fR 选项,则忽略 \fB-e\fR 和 \fB-t\fR 选项。 .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fIfile\fR\fR .ad .RS 8n .rt 输入文件的路径名称。如果未指定 \fIfile\fR,则使用标准输入。如果 \fIfile\fR 为 \fB - \fR,则 \fBcat\fR 从序列中的该点读取标准输入。当以这种方法引用时,\fBcat\fR 不关闭和重新打开标准输入,但是接受多次出现的 \fB - \fR 作为 \fIfile\fR。 .RE .SH 用法 .sp .LP 有关 \fBcat\fR 遇到大于或等于 2 GB(2^31 字节)文件时行为的说明,请参见 \fBlargefile\fR(5)。 .SH 示例 .LP \fB示例 1 \fR串联文件 .sp .LP 下面的命令将 \fBmyfile\fR 文件的内容写入标准输出: .sp .in +2 .nf example% \fBcat myfile\fR .fi .in -2 .sp .LP \fB示例 2 \fR将两个文件串联成一个文件 .sp .LP 下面的命令串联 \fBdoc1\fR 文件和 \fBdoc2\fR 文件,并将结果写入 \fBdoc.all\fR。 .sp .in +2 .nf example% \fBcat doc1 doc2 > doc.all\fR .fi .in -2 .sp .LP \fB示例 3 \fR通过单次调用串联输入的两个任意片段 .sp .LP 当标准输入为终端时,下面的命令通过单次调用 \fBcat\fR 从终端获取输入的两个任意片段: .sp .in +2 .nf example% \fBcat start - middle - end > file\fR .fi .in -2 .sp .sp .LP 当标准输入为终端时,通过单次调用 \fBcat\fR 从终端获取输入的两个任意片段。 .sp .LP 如果标准输入为常规文件, .sp .in +2 .nf example% \fBcat start - middle - end > file\fR .fi .in -2 .sp .sp .LP 则等效于下面的命令: .sp .in +2 .nf \fBcat start - middle /dev/null end > file\fR .fi .in -2 .sp .sp .LP 由于第一次将 \fB - \fR 用作 \fIfile\fR 操作数时 \fBcat\fR 会使用文件的全部内容,因此在第二次引用 \fB - \fR 时可以立即检测到文件末尾条件。 .SH 环境变量 .sp .LP 有关影响 \fBcat\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLANG\fR、\fBLC_ALL\fR、\fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR。 .SH 退出状态 .sp .LP 将返回以下退出值: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt 所有输入文件都已成功输出。 .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt 出现错误。 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/core-os _ CSIEnabled(已启用) _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SH 另请参见 .sp .LP \fBtouch\fR(1)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBlargefile\fR(5)、\fBstandards\fR(5) .SH 附注 .sp .LP 将 \fBcat\fR 的输出重定向到正在读取的文件之一会导致正在读取文件原来的数据丢失。例如, .sp .in +2 .nf example% \fBcat filename1 filename2 > filename1\fR .fi .in -2 .sp .sp .LP 导致 \fBfilename1\fR 中原来的数据丢失。