sort <file> | uniqRemoves duplicate lines. uniq only compares neighbours, so sort first.
Example
sort ips.txt | uniqFilters or counts adjacent duplicate lines — usually paired with sort.
sudo apt install coreutilssort <file> | uniqRemoves duplicate lines. uniq only compares neighbours, so sort first.
Example
sort ips.txt | uniqsort <file> | uniq -cPrefixes each line with how many times it occurs.
Example
sort ips.txt | uniq -csort <file> | uniq -c | sort -rnFrequency ranking — the most common lines first.
Example
sort ips.txt | uniq -c | sort -rn | headsort <file> | uniq -dPrints only lines that appear more than once.
Example
sort users.txt | uniq -dsort <file> | uniq -uPrints only lines that appear exactly once.
Example
sort users.txt | uniq -usort <file> | uniq -iIgnores case when comparing.
Example
sort -f names.txt | uniq -iuniq -f <n> <file>Skips the first n fields when comparing — useful when lines start with timestamps.
Example
uniq -f 1 events.txtuniq -s <n> <file>Skips the first n characters when comparing.
Example
uniq -s 20 log.txtuniq -w <n> <file>Compares only the first n characters.
Example
uniq -w 12 macs.txtSorts lines of text alphabetically, numerically, by field or by human-readable size.
Counts lines, words, characters and bytes in files or input.
Concatenates files and prints them to standard output — view, combine and create files.
A pager for viewing large files and command output one screen at a time, with search and follow mode.
Prints the first lines or bytes of files — quick previews of logs and data.
Prints the last lines of files and follows them as they grow — the standard way to watch logs.