0%
uniq
- 以每一行為單位,相鄰兩行內容重複的話,uniq 將會去除重複的行
params
- -c, –count
- prefix lines by the number of occurrences
- -d, –repeated
- only print duplicate lines, one for each group
- -D
- print all duplicate lines
- –all-repeated[=METHOD]
- like -D, but allow separating groups with an empty line; METHOD={none(default),prepend,separate}
- -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
- -s, –skip-chars=N
- avoid comparing the first N characters
- -u, –unique
- -z, –zero-terminated
- line delimiter is NUL, not newline
- -w, –check-chars=N
- compare no more than N characters in lines
count
1 2
| # uniq 若加上 -c 參數,可以在刪除重複文字行之後,標示出每一行的重複次數: uniq -c example1.txt
|
print line
1 2 3 4 5 6
| # 若只要輸出有重複的文字行 uniq -D example1.txt # 要將這個輸出中重複的行刪掉 uniq -d example1.txt # 輸出沒有重複的文字行,也就是說只要出現重複的文字行,就完全刪掉 uniq -u example1.txt
|
reference