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(必须相邻),布布扣,bubuko.com

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

上一篇:关于linux批量改文件名问题


下一篇:Linux 指令篇:文本统计--wc(word count)