文章目录
前言
大家好,又见面了,我是沐风晓月,本文是专栏【linux基本功-基础命令实战】的第51篇文章。
专栏地址:[linux基本功-基础命令专栏] , 此专栏是沐风晓月对Linux常用命令的汇总,希望能够加深自己的印象,以及帮助到其他的小伙伴😉😉。
如果文章有什么需要改进的地方还请大佬不吝赐教👏👏。
🏠个人主页:我是沐风晓月
🧑个人简介:大家好,我是沐风晓月,双一流院校计算机专业😉😉
💕 座右铭: 先努力成长自己,再帮助更多的人 ,一起加油进步🍺🍺🍺
💕欢迎大家:这里是CSDN,我总结知识的地方,喜欢的话请三连,有问题请私信😘
一. uniq的命令介绍
uniq用户重复数据的处理,使用前先用sort进行排序
主要用途有两个:
- 将输入文件(或标准输入)中邻近的重复行写入到输出文件(或标准输出)中。
- 当没有选项时,邻近的重复行将合并为一个。
二. 语法格式及常用选项
依据惯例,我们还是先查看帮助,使用 uniq --help
[root@mufeng ~]# uniq --help
用法:uniq [选项]... [文件]
Filter adjacent matching lines from INPUT (or standard input),
writing to OUTPUT (or standard output).
With no options, matching lines are merged to the first occurrence.
Mandatory arguments to long options are mandatory for short options too.
-c, --count prefix lines by the number of occurrences
-d, --repeated only print duplicate lines, one for each group
-D, --all-repeated[=METHOD] print all duplicate lines
groups can be delimited with an empty line
METHOD={
none(default),prepend,separate}
-f, --skip-fields=N avoid comparing the first N fields
--group[=METHOD