Linux 指令篇:文本排序--uniq(必须相邻)

NAME
    uniq - report or omit repeated lines

SYNOPSIS
    uniq [OPTION]... [INPUT [OUTPUT]]

DESCRIPTION
    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

    -D, --all-repeated[=delimit-method]
      print all duplicate lines delimit-method={none(default),prepend,separate} Delimiting is done with blank lines.

    -u, --unique
      only print unique lines

================================================================================

e.g.1

[root@localhost tmp]# cat num.txt
111
111
667
999
111    /*此处与L1 L2不相邻 不作为重复统计*/


[root@localhost tmp]# uniq -d num.txt
111


[root@localhost tmp]# uniq -D num.txt
111
111


[root@localhost tmp]# uniq -c num.txt
2 111
1 667
1 999
1 111

Linux 指令篇:文本排序--uniq(必须相邻),古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。