Report or omit duplicate lines报告或省略重复的行
The uniq command filters adjacent matching lines from input. Important: It only removes adjacent duplicates, so input should typically be sorted first. It's commonly used with sort to clean up data files.
uniq命令从输入中过滤相邻的匹配行。重要:它只删除相邻的重复项,所以输入通常应该先排序。它通常与sort一起使用来清理数据文件。
| Option选项 | Full Name完整名称 | Description描述 | Example示例 |
|---|---|---|---|
-c |
count计数 | Prefix with occurrence count加上出现次数前缀 | uniq -c items.txt |
-d |
repeated重复 | Show only duplicate lines仅显示重复的行 | uniq -d items.txt |
-u |
unique唯一 | Show only unique lines仅显示唯一的行 | uniq -u items.txt |
-i |
ignore-case忽略大小写 | Case-insensitive comparison不区分大小写比较 | uniq -i items.txt |
-D |
all-repeated所有重复 | Show all duplicate lines显示所有重复的行 | uniq -D items.txt |
✨ "uniq" = unique - Make lines unique (remove adjacent duplicates)
✨ "uniq" = unique(唯一) - 使行唯一(删除相邻的重复项)
📊 -c = Count - Count how many times each line appears
📊 -c = Count(计数) - 计算每行出现多少次
👯 -d = Duplicates - Show only lines that are duplicated
👯 -d = Duplicates(重复) - 仅显示重复的行
⚠️ uniq requires sorted input! - Always sort first (or use sort -u)
⚠️ uniq需要排序的输入! - 始终先排序(或使用sort -u)