.\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" the Institute of Electrical and Electronics Engineers, Inc. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" From: @(#)uniq.1 8.1 (Berkeley) 6/6/93 .\" %Id: uniq.1,v 1.3 1997/09/07 15:09:22 joerg Exp % .\" jpman %Id: uniq.1,v 1.2 1997/03/29 11:56:16 horikawa Stab % .\" .Dd June 6, 1993 .Dt UNIQ 1 .Os .Sh 名称 .Nm uniq .Nd ファイル内の重複行の報告または、フィルタ出力 .Sh 書式 .Nm .Op Fl c | Fl d | Fl u .Op Fl i .Op Fl f Ar fields .Op Fl s Ar chars .Oo .Ar input_file .Op Ar output_file .Oc .Sh 解説 .Nm ユーティリティは、標準入力を読み込み、隣り合う行同士を比較し、 重複した行を取り除いて標準出力へ書き込みます。 隣り合った行が同じ内容だったら 2 行目以降を出力しません。 同じ内容でも行が隣り合っていない場合は比較の対象になりませんので、 まずファイルをソートする事が必要になるかもしれません。 .Pp オプションとしては以下のものがあります: .Bl -tag -width Ds .It Fl c 各出力行の先頭に、行が入力中に続けて出現した回数を表示し、空白一つあけて その行の内容を表示します。 .It Fl d 重複した行のみを出力します。 .It Fl f Ar fields 比較する時に、各入力行の先頭から .Ar fields 個のフィールドを無視します。 フィールドとは、空白文字で区切られた、空白以外の文字からなる文字列です。 .Ar fields を指定するときは、最初のフィールドを 1 として数えます。 .It Fl s Ar chars 比較する時に、各入力行の先頭から .Ar chars 文字を無視します。 本オプションを .Fl f オプションと一緒に指定した場合は、 .Ar fields 個のフィールドに続く .Ar chars 文字が無視されます。 .Ar chars を指定するときは、最初の文字を 1 として数えます。 .It Fl u 入力の重複がなかった行のみを出力します。 .It Fl i 行の比較において大文字小文字を区別しません。 .\".It Fl Ns Ar n .\"(Deprecated; replaced by .\".Fl f ) . .\"Ignore the first n .\"fields on each input line when doing comparisons, .\"where n is a number. .\"A field is a string of non-blank .\"characters separated from adjacent fields .\"by blanks. .\".It Cm \&\(pl Ns Ar n .\"(Deprecated; replaced by .\".Fl s ) . .\"Ignore the first .\".Ar m .\"characters when doing comparisons, where .\".Ar m .\"is a .\"number. .El .Pp コマンドラインにさらに引数が指定されると、その最初の引数を入力ファイルの 名前として使用し、その次の引数を出力ファイルの名前として使用します。 .Pp .Nm ユーティリティは、成功した場合は 0 を、 エラーが発生した場合は 0 より大きな値を返します。 .Sh 互換性 古くからある .Cm \&\(pl Ns Ar number と .Fl Ns Ar number のオプションは時代遅れですが、この実装ではまだサポートしています。 .Sh 関連項目 .Xr sort 1 .Sh 規格 .Nm ユーティリティは、 .St -p1003.2 互換であるはずです。