2019年10月25日 星期五

uniq - remove duplicate lines from a sorted file (從排序的文件中刪除重複的行)




uniq

From Wikipedia, the free encyclopedia
uniq
Original author(s)Ken Thompson
Developer(s)AT&T Bell Laboratories
Initial releaseFebruary 1973; 46 years ago
Operating systemUnix and Unix-likeMSX-DOS
TypeCommand
LicenseGNU GPL v3
Websitehttp://man7.org/linux/man-pages/man1/uniq.1.html

uniq - remove duplicate lines from a sorted file  
          從排序的文件中刪除重複的行

uniq is a Unix utility which, when fed a text file or STDIN, outputs the text with adjacent identical lines collapsed to one, unique line of text.
uniqUnix實用程序,當輸入文本文件STDIN時,它以折疊的相鄰相同行輸出為一行唯一的文本來輸出文本。

Overview[edit]
The command is a kind of filter program. Typically it is used after sort該命令是一種過濾程序通常在之後使用sort

It can also output only the duplicate lines (with the -d option), 它還可以僅輸出重複的行(帶-d選項)
or add the number of occurrences of each line (with the -c option). 或增加每行的出現次數(帶-c選項)。
An example: To see the list of lines in a file, sorted by the number of times each occurs:
一個示例:要查看文件中的行列表,按行出現的次數排序:
sort file | uniq -c | sort -n
Using uniq like this is common when building pipelines in shell scripts.
shell腳本中構建管道時通常會像這樣使用uniq 


沒有留言:

張貼留言