uniq.c revision 1
1N/A/*********************************************************************** 1N/A* This software is part of the ast package * 1N/A* Copyright (c) 1992-2011 AT&T Intellectual Property * 1N/A* and is licensed under the * 1N/A* Common Public License, Version 1.0 * 1N/A* by AT&T Intellectual Property * 1N/A* A copy of the License is available at * 1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 1N/A* Information and Software Systems Research * 1N/A* Glenn Fowler <gsf@research.att.com> * 1N/A* David Korn <dgk@research.att.com> * 1N/A***********************************************************************/ 1N/A * Written by David Korn 1N/A"[-n?\n@(#)$Id: uniq (AT&T Research) 2009-11-28 $\n]" 1N/A"[+NAME?uniq - Report or filter out repeated lines in a file]" 1N/A"[+DESCRIPTION?\buniq\b reads the input, compares adjacent lines, and " 1N/A "writes one copy of each input line on the output. The second " 1N/A "and succeeding copies of the repeated adjacent lines are not " 1N/A"[+?If the output file, \aoutfile\a, is not specified, \buniq\b writes " 1N/A "to standard output. If no \ainfile\a is given, or if the \ainfile\a " 1N/A "is \b-\b, \buniq\b reads from standard input with the start of " 1N/A "the file defined as the current offset.]" 1N/A"[c:count?Output the number of times each line occurred along with " 1N/A"[d:repeated|duplicates?Output the first of each duplicate line.]" 1N/A"[D:all-repeated?Output all duplicate lines as a group with an empty " 1N/A "line delimiter specified by \adelimit\a:]:?[delimit:=none]" 1N/A "[n:none?Do not delimit duplicate groups.]" 1N/A "[p:prepend?Prepend an empty line before each group.]" 1N/A "[s:separate?Separate each group with an empty line.]" 1N/A"[f:skip-fields]#[fields?\afields\a is the number of fields to skip over " 1N/A "before checking for uniqueness. A field is the minimal string matching " 1N/A "the BRE \b[[:blank:]]]]*[^[:blank:]]]]*\b. -\anumber\a is equivalent to " 1N/A "\b--skip-fields\b=\anumber\a.]" 1N/A"[i:ignore-case?Ignore case in comparisons.]" 1N/A"[s:skip-chars]#[chars?\achars\a is the number of characters to skip over " 1N/A "before checking for uniqueness. If specified along with \b-f\b, " 1N/A "the first \achars\a after the first \afields\a are ignored. If " 1N/A "the \achars\a specifies more characters than are on the line, " 1N/A "an empty string will be used for comparison. +\anumber\a is " 1N/A "equivalent to \b--skip-chars\b=\anumber\a.]" 1N/A"[u:unique?Output unique lines.]" 1N/A"[w:check-chars]#[chars?\achars\a is the number of characters to compare " 1N/A "after skipping any specified fields and characters.]" 1N/A"\n[infile [outfile]]\n" 1N/A "[+0?The input file was successfully processed.]" 1N/A "[+>0?An error occurred.]" 1N/A"[+SEE ALSO?\bsort\b(1), \bgrep\b(1)]" 1N/A while (f-->0 &&
cp<
ep)
/* skip over fields */ 1N/A /* save current record */ 1N/A /* no room in outp, clear lock and use side buffer */ 1N/A error(
2,
"-c and -D are mutually exclusive");