Linux命令之uniq
来源:互联网 发布:社交关系网络量化建模 编辑:程序博客网 时间:2024/05/29 18:35
学习笔记:<linux shell编程>书籍
命令:uniq
语法:sort [arg] [File]
功能:文本去重
参数:
Usage: uniq [OPTION]... [INPUT [OUTPUT]]
Discard all but one of successive identical lines from INPUT (or
standard input), writing to OUTPUT (or standard output).
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
-D, --all-repeated[=delimit-method] print all duplicate lines
delimit-method={none(default),prepend,separate}
Delimiting is done with blank lines.
-f, --skip-fields=N avoid comparing the first N fields
-i, --ignore-case ignore differences in case when comparing
-s, --skip-chars=N avoid comparing the first N characters
-u, --unique only print unique lines
-z, --zero-terminated end lines with 0 byte, not newline
-w, --check-chars=N compare no more than N characters in lines
--help display this help and exit
--version output version information and exit
实例1. 去除重复项
test@node-h:~/Jeff> cat fruits_2.txt
apples
apples
peaches
pears
bananas
cherries
cherries
解释:显示fruits_2.txt文本
test@node-h:~/Jeff> uniq fruits_2.txt
apples
peaches
pears
bananas
cherries
解释:不加任何参数,去除fruits_2.txt的重复行。
实例2. 去除重复项,并显示重复的次数
test@node-h:~/Jeff> sort fruits_2.txt | uniq -c
2 apples
1 bananas
2 cherries
1 peaches
1 pears
解释:参数-c 显示重复的次数
实例3. 去除重复项,并仅显示重复行
test@node-h:~/Jeff> sort fruits_2.txt | uniq -d
apples
cherries
解释:-d 仅仅显示重复行
实例3. 去除重复项,并显示不重复行
test@node-h:~/Jeff> sort fruits_2.txt | uniq -u
bananas
peaches
Pears
解释:-u 显示不重复行
命令:uniq
语法:sort [arg] [File]
功能:文本去重
参数:
Usage: uniq [OPTION]... [INPUT [OUTPUT]]
Discard all but one of successive identical lines from INPUT (or
standard input), writing to OUTPUT (or standard output).
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
-D, --all-repeated[=delimit-method] print all duplicate lines
delimit-method={none(default),prepend,separate}
Delimiting is done with blank lines.
-f, --skip-fields=N avoid comparing the first N fields
-i, --ignore-case ignore differences in case when comparing
-s, --skip-chars=N avoid comparing the first N characters
-u, --unique only print unique lines
-z, --zero-terminated end lines with 0 byte, not newline
-w, --check-chars=N compare no more than N characters in lines
--help display this help and exit
--version output version information and exit
实例1. 去除重复项
test@node-h:~/Jeff> cat fruits_2.txt
apples
apples
peaches
pears
bananas
cherries
cherries
解释:显示fruits_2.txt文本
test@node-h:~/Jeff> uniq fruits_2.txt
apples
peaches
pears
bananas
cherries
解释:不加任何参数,去除fruits_2.txt的重复行。
实例2. 去除重复项,并显示重复的次数
test@node-h:~/Jeff> sort fruits_2.txt | uniq -c
2 apples
1 bananas
2 cherries
1 peaches
1 pears
解释:参数-c 显示重复的次数
实例3. 去除重复项,并仅显示重复行
test@node-h:~/Jeff> sort fruits_2.txt | uniq -d
apples
cherries
解释:-d 仅仅显示重复行
实例3. 去除重复项,并显示不重复行
test@node-h:~/Jeff> sort fruits_2.txt | uniq -u
bananas
peaches
Pears
解释:-u 显示不重复行
0 0
- Linux命令之uniq
- Linux命令之uniq
- Linux命令之uniq命令使用详解
- 图解Linux命令之--uniq命令
- linux命令之uniq sort cut
- linux uniq命令用法
- linux uniq命令
- linux uniq命令详解
- linux uniq使用命令
- linux uniq使用命令
- 【转帖】Linux Uniq命令
- linux uniq命令
- linux uniq命令
- linux uniq 命令详解
- linux uniq 命令介绍
- linux uniq命令详解
- linux uniq命令详解
- Linux uniq命令
- IOS中.pch的使用
- wifi模块ESP8266_AT arduino 库文件部分方法解析及优化
- json的一点小研究
- Linux源代码分析工具链
- iOS UIScrollView常用属性、回调方法
- Linux命令之uniq
- iOS开发之使用Xcode和Instruments调试解决iOS内存泄露
- OpenTsdb 写入数据
- 开发protobuf扩展的一些笔记
- 分治法的经典问题——大整数相乘
- LinqQuery
- 一个简易的java自带的观察者模式实现
- 交换两个数值变量值得算法
- IOS常用宏定义