Linux uniq命令

uniq常见参数

在每行前加上目前出现次数的编号
-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}

比较时跳过前N列
-f, --skip-fields=N avoid comparing the first N fields
–group[=METHOD] show all items, separating groups with an empty line
METHOD={separate(default),prepend,append,both}

比较时,忽略大小写
-i, --ignore-case ignore differences in case when comparing
比较时跳过前N 个字符
-s, --skip-chars=N avoid comparing the first N characters

去除重复的行
-u, --unique only print unique lines

使用’\0’作为行结束符,而不是新换行
-z, --zero-terminated end lines with 0 byte, not newline

对每行第N 个字符以后的内容不作对照
-w, --check-chars=N compare no more than N characters in lines

帮助
–help display this help and exit

版本
–version output version information and exit

例子

[root@hdfa67 txt]# cat word
the day is sunny the the
the sunny is is
[root@hdfa67 txt]# cat word |xargs -n 1
the
day
is
sunny
the
the
the
sunny
is
is

  • -c
[root@hdfa67 txt]# cat word |xargs -n 1 | sort | uniq -c
      1 day
      3 is
      2 sunny
      4 the
[root@hdfa67 txt]# cat word |xargs -n 1 | uniq -c
      1 the
      1 day
      1 is
      1 sunny
      3 the
      1 sunny
      2 is

  • -d
[root@hdfa67 txt]# cat word |xargs -n 1 | uniq -d
the
is
  • -D
[root@hdfa67 txt]# cat word |xargs -n 1 | uniq -D
the
the
the
is
is
  • -u
[root@hdfa67 txt]# cat word |xargs -n 1 
the
day
is
sunny
sunny
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值