Uniq
Original: http://blog.csdn.net/xifeijian/article/details/9209627
The Uniq command removes duplicate rows from a sorted file, so Uniq is often used in combination with sort. That is, in order for the Uniq to work, all duplicate rows must be contiguous.
Uniq syntax
[[email protected] ~]# uniq [-ICU] options and Parameters: -I: Ignoring the difference between uppercase and lowercase characters;-C : Count-u : Only show unique rows
The contents of Testfile are as follows
Cat Testfilehelloworldfriendhelloworldhello
Deleting an unordered file directly will reveal that no rows have been deleted
#uniq testfile Helloworldfriendhelloworldhello
Sort files, the default is to go to heavy
#cat Words | Sort |uniqfriendhelloworld
Duplicate rows are deleted after sorting, and the number of occurrences of the row is output at the beginning of the line
#sort Testfile | UNIQ-C1 Friend3 Hello2 World
Displays only duplicate rows, and displays the number of repetitions of the row at the beginning of the line
#sort Testfile | UNIQ-DC3 Hello2 World
Show only rows that are not duplicates
Sort Testfile | Uniq-ufriend
Go Shell script Programming--uniq command