uniq
all
Output the unique lines from an input or file. Since it does not detect repeated lines unless they are adjacent, we need to sort them first. See also: `sort`.
More info →Options (6)
-u, --uniquebooleanDisplay only unique lines
Example:
sort {{path/to/file}} | uniq {{[-u|--unique]}}-d, --repeatedbooleanDisplay only duplicate lines
Example:
sort {{path/to/file}} | uniq {{[-d|--repeated]}}-c, --countbooleanDisplay number of occurrences of each line along with that line
Example:
sort {{path/to/file}} | uniq {{[-c|--count]}}booleanDisplay number of occurrences of each line, sorted by the most frequent
Example:
sort {{path/to/file}} | uniq {{[-c|--count]}} | sort {{[-nr|--numeric-sort --reverse]}}-w, --check-charsbooleanCompare only the first 10 characters on each line for uniqueness
Example:
sort {{path/to/file}} | uniq {{[-w|--check-chars]}} 10-s, --skip-charsbooleanCompare text after the first 5 characters on each line for uniqueness
Example:
sort {{path/to/file}} | uniq {{[-s|--skip-chars]}} 5Examples (7)
Display number of occurrences of each line along with that line
Display number of occurrences of each line, sorted by the most frequent
Compare only the first 10 characters on each line for uniqueness
made by @shridhargupta | data from tldr-pages