144 lines
3.6 KiB
HTML
144 lines
3.6 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content=
|
|
"text/html; charset=utf-8">
|
|
<title>uniq - Report or filter out repeated lines in a file</title>
|
|
<LINK rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
|
</HEAD>
|
|
<body bgcolor="#FFFFFF">
|
|
<!-- Java sync-link -->
|
|
<SCRIPT LANGUAGE="Javascript" SRC="../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
|
|
|
|
|
|
|
|
<h2>uniq - Report or filter out repeated lines in a file</h2>
|
|
|
|
<p><strong>Synopsis</strong></p>
|
|
|
|
<p><strong>uniq [-c | -du] [-f</strong> <em>fields</em><strong>]
|
|
[-s</strong> <em>chars</em><strong>]</strong> [<em>input_file</em>
|
|
[<em>output_file</em>]]</p>
|
|
|
|
<p><strong>Description</strong></p>
|
|
|
|
<p>The <strong>uniq</strong> utility reads the standard input
|
|
comparing adjacent lines, and writes a copy of each unique input
|
|
line to the standard output. The second and succeeding copies of
|
|
identical adjacent input lines are not written. Repeated lines in
|
|
the input will not be detected if they are not adjacent, so it may
|
|
be necessary to sort the files first.</p>
|
|
|
|
<p><strong>Options</strong></p>
|
|
|
|
<dl>
|
|
<dt><strong>-c</strong></dt>
|
|
|
|
<dd>Precede each output line with the count of the number of times
|
|
the line occurred in the input, followed by a single space.</dd>
|
|
|
|
<dt><strong>-d</strong></dt>
|
|
|
|
<dd>Suppress the writing of lines that are not repeated in the
|
|
input.</dd>
|
|
|
|
<dt><strong>-f</strong> <em>fields</em></dt>
|
|
|
|
<dd>Ignore the first <em>fields</em> fields in each input line when
|
|
doing comparisons. A field is a string of non-blank characters
|
|
separated from adjacent fields by blanks. Field numbers are one
|
|
based, so the first field is field one.</dd>
|
|
|
|
<dt><strong>-s</strong> <em>chars</em></dt>
|
|
|
|
<dd>Ignore the first <em>chars</em> characters in each input line
|
|
when doing comparisons. If specified in conjunction with the
|
|
<strong>-f</strong> option, the first <em>chars</em> characters
|
|
after the first <em>fields</em> fields will be ignored. Character
|
|
numbers are one based, so the first character is character
|
|
one.</dd>
|
|
|
|
<dt><strong>-u</strong></dt>
|
|
|
|
<dd>Suppress the writing of lines that are repeated in the
|
|
input.</dd>
|
|
</dl>
|
|
|
|
<p><strong>Operands</strong></p>
|
|
|
|
<p>If additional arguments are specified on the command line, the
|
|
first such argument is used as the name of an input file, the
|
|
second is used as the name of an output file.</p>
|
|
|
|
<p><strong>Exit Status</strong></p>
|
|
|
|
<ul>
|
|
<li>0 on success</li>
|
|
|
|
<li>>0 if an error occurs</li>
|
|
</ul>
|
|
|
|
<p><strong>Related information</strong></p>
|
|
|
|
<ul>
|
|
<li><a href="cmp.htm">cmp - Compare two files</a></li>
|
|
|
|
<li><a href="sed.htm">sed - Stream editor</a></li>
|
|
|
|
<li><a href="split.htm">split - Split files into pieces</a></li>
|
|
|
|
<li><a href="sort.htm">sort - Sort, merge, or sequence check text
|
|
files</a></li>
|
|
</ul>
|
|
|
|
<p><strong>Examples</strong></p>
|
|
|
|
<p>In the following examples, the contents of example file are:</p>
|
|
|
|
<pre>
|
|
There are 5 apples
|
|
There are 9 oranges
|
|
There are 9 oranges
|
|
There are 2 pears
|
|
</pre>
|
|
|
|
<ol>
|
|
<li>Display the unique lines in the file "fruit".
|
|
|
|
<pre>
|
|
uniq fruit
|
|
|
|
There are 5 apples
|
|
There are 9 oranges
|
|
There are 2 pears
|
|
</pre>
|
|
</li>
|
|
|
|
<li>Display the lines that repeat in the file "fruit".
|
|
|
|
<pre>
|
|
uniq -d fruit
|
|
|
|
There are 9 oranges
|
|
</pre>
|
|
</li>
|
|
|
|
<li>Display a list of how many times a line is repeated in the file
|
|
"fruit".
|
|
|
|
<pre>
|
|
uniq -c fruit
|
|
|
|
1 There are 5 apples
|
|
2 There are 9 oranges
|
|
1 There are 2 pears
|
|
</pre>
|
|
</li>
|
|
</ol>
|
|
|
|
<!-- end ibmbody========================================================= -->
|
|
</body>
|
|
</html>
|
|
|