uniq - report or omit repeated lines
默认只输出不重复的行(相当于去掉重复的行)
[useputty_login@PC_IN_LAN ~]$cat a
boy took bat home
boy took bat home
girl took bat home
dog brought hat home
dog brought hat home
dog brought hat home
[useputty_login@PC_IN_LAN ~]$uniq a
boy took bat home
girl took bat home
dog brought hat home
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-c 选项在行前面打印数字表示该行在文件中出现几次(重复几次)
[useputty_login@PC_IN_LAN ~]$uniq -c a
2 boy took bat home
1 girl took bat home
3 dog brought hat home
-d 只输出重复的行(输出一行)
[useputty_login@PC_IN_LAN ~]$uniq -d -c a
2 boy took bat home
3 dog brought hat home
-D 输出重复行的全部行
[useputty_login@PC_IN_LAN ~]$uniq -D a
boy took bat home
boy took bat home
dog brought hat home
dog brought hat home
dog brought hat home
-u 只打印出现过一次的行
[useputty_login@PC_IN_LAN ~]$uniq -u a
girl took bat home
-f N 忽略前N个域
a 23 45 23 45 34 36 23 45
b 23 45 23 45 34 36 23 45
c 23 53 23 56 23 45 67 23
把相同的行找出来 打印 如:
a 23 45 23 45 34 36 23 45
b 23 45 23 45 34 36 23 45
[useputty_login@PC_IN_LAN ~]$uniq -f 1 -D a
a 23 45 23 45 34 36 23 45
b 23 45 23 45 34 36 23 45
表示忽略第一个域 并打出所有重复行
[useputty_login@PC_IN_LAN ~]$uniq -f 2 -D a
a c 23 45 23 45 34 36 23 45
b d 23 45 23 45 34 36 23 45
从这可以看出是忽略第N个域前的所有域。
-c 与 -f 一样只是忽略的是第N个字符前面的所有字符。
阅读(3494) | 评论(1) | 转发(0) |