mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-08 15:04:05 +08:00
33 lines
1.7 KiB
HTML
33 lines
1.7 KiB
HTML
<h1 id="uniq">uniq</h1>
|
||
<p>报告或忽略文件中的重复行</p>
|
||
<h2 id="补充说明">补充说明</h2>
|
||
<p><strong>uniq命令</strong> 用于报告或忽略文件中的重复行,一般与sort命令结合使用。</p>
|
||
<h3 id="语法">语法</h3>
|
||
<pre><code class="language-bash">uniq(选项)(参数)</code></pre>
|
||
<h3 id="选项">选项</h3>
|
||
<pre><code class="language-bash">-c或——count:在每列旁边显示该行重复出现的次数;
|
||
-d或--repeated:仅显示重复出现的行列;
|
||
-f<栏位>或--skip-fields=<栏位>:忽略比较指定的栏位;
|
||
-s<字符位置>或--skip-chars=<字符位置>:忽略比较指定的字符;
|
||
-u或——unique:仅显示出一次的行列;
|
||
-w<字符位置>或--check-chars=<字符位置>:指定要比较的字符。</code></pre>
|
||
<h3 id="参数">参数</h3>
|
||
<ul>
|
||
<li>输入文件:指定要去除的重复行文件。如果不指定此项,则从标准读取数据;</li>
|
||
<li>输出文件:指定要去除重复行后的内容要写入的输出文件。如果不指定此选项,则将内容显示到标准输出设备(显示终端)。</li>
|
||
</ul>
|
||
<h3 id="实例">实例</h3>
|
||
<p>删除重复行:</p>
|
||
<pre><code class="language-bash">uniq file.txt
|
||
sort file.txt | uniq
|
||
sort -u file.txt
|
||
</code></pre>
|
||
<p>只显示单一行:</p>
|
||
<pre><code class="language-bash">uniq -u file.txt
|
||
sort file.txt | uniq -u</code></pre>
|
||
<p>统计各行在文件中出现的次数:</p>
|
||
<pre><code class="language-bash">sort file.txt | uniq -c</code></pre>
|
||
<p>在文件中找出重复的行:</p>
|
||
<pre><code class="language-bash">sort file.txt | uniq -d</code></pre>
|
||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|