'\" te .\" Copyright (c) 2009, 2011, 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 comm 1 "2011 年 7 月 26 日" "SunOS 5.11" "用户命令" .SH 名称 comm \- 选择或拒绝两个文件共有的行 .SH 用法概要 .LP .nf \fB/usr/bin/comm\fR [\fB-\fIoptions\fR\fR] \fIfile1\fR \fIfile2\fR .fi .SH 描述 .sp .LP \fBcomm\fR 的作用是读取应该按当前语言环境下的整理序列排序的两个文件 \fIfile1\fR 和 \fIfile2\fR,生成三个文本列作为输出: .sp .ne 2 .mk .na \fB1\fR .ad .RS 5n .rt 仅 \fIfile1\fR 中有的行。 .RE .sp .ne 2 .mk .na \fB2\fR .ad .RS 5n .rt 仅 \fIfile2\fR 中有的行。 .RE .sp .ne 2 .mk .na \fB3\fR .ad .RS 5n .rt 两个文件中都有的行。 .RE .sp .LP 如果任一文件中的行未按当前语言环境下的整理序列排序,则无法得到结果。 .sp .LP 如果 \fIfile1\fR 或 \fIfile2\fR 为 \fB-\fR,\fBcomm\fR 将从当前位置开始使用标准输入。 .SH 选项 .sp .LP 支持以下选项: .sp .ne 2 .mk .na \fB\fB-1\fR\fR .ad .RS 6n .rt 不输出仅 \fIfile1\fR 中有的行对应的列。 .RE .sp .ne 2 .mk .na \fB\fB-2\fR\fR .ad .RS 6n .rt 不输出仅 \fIfile2\fR 中有的行对应的列。 .RE .sp .ne 2 .mk .na \fB\fB-3\fR\fR .ad .RS 6n .rt 不输出 \fIfile1\fR 和 \fIfile2\fR 中重复的行对应的列。 .RE .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fIfile1\fR\fR .ad .RS 9n .rt 要比较的第一个文件的路径名。如果 \fIfile1\fR 为 \fB-\fR,则使用标准输入。 .RE .sp .ne 2 .mk .na \fB\fIfile2\fR\fR .ad .RS 9n .rt 要比较的第二个文件的路径名。如果 \fIfile2\fR 为 \fB-\fR,则使用标准输入。 .RE .SH 用法 .sp .LP 有关 \fBcomm\fR 遇到大于或等于 2 GB(2^31 字节)文件时行为的说明,请参见 \fBlargefile\fR(5)。 .SH 示例 .LP \fB示例 1 \fR列显文件指定的实用程序列表 .sp .LP 如果 \fIfile1\fR、\fIfile2\fR 和 \fIfile3\fR 每个都包含已排序的实用程序列表,则命令: .sp .in +2 .nf example% \fBcomm -23 file1 file2 | comm -23 - file3\fR .fi .in -2 .sp .sp .LP 将列显 \fIfile1\fR 中未由其他两个文件指定的实用程序的列表。命令: .sp .in +2 .nf example% \fBcomm -12 file1 file2 | comm -12 - file3\fR .fi .in -2 .sp .sp .LP 将列显全部三个文件均指定的实用程序的列表。命令: .sp .in +2 .nf example% \fBcomm -12 file2 file3 | comm -23 -file1\fR .fi .in -2 .sp .sp .LP 将列显由 \fIfile2\fR 和 \fIfile3\fR 指定但未在 \fIfile1\fR 中指定的实用程序的列表。 .SH 环境变量 .sp .LP 有关影响 \fBcomm\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLANG\fR、\fBLC_ALL\fR、\fBLC_COLLATE\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 \fBcmp\fR(1)、\fBdiff\fR(1)、\fBsort\fR(1)、\fBuniq\fR(1)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBlargefile\fR(5)、\fBstandards\fR(5)