uniq
ShellFundamentals In simulator In real LinuxCollapse adjacent duplicate lines
Name: uniq = unique
You can practise it right away in the simulator, and use it in real Linux mode too.
Description
uniq collapses **adjacent** duplicate lines into one. Since it only compares neighbours, input is usually sorted first; "sort | uniq -c | sort -rn" is the classic way to count occurrences.
Syntax
uniq [OPTION]... [INPUT [OUTPUT]]Common options
| -c / --count | Prefix lines with their count |
| -d / --repeated | Only print duplicated lines |
| -u / --unique | Only print unique lines |
| -i / --ignore-case | Ignore case when comparing |
| -f / --skip-fields N | Skip the first N fields when comparing |
| -s / --skip-chars N | Skip the first N characters when comparing |
| -w / --check-chars N | Compare only the first N characters |