Linux Command Directory
This directory of Linux commands is from Linux in a Nutshell, 5th Edition.
Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.
Buy it now, or read it online on Safari Bookshelf.
uniq
uniq [options] [file1 [file2] ]
Remove duplicate adjacent lines from sorted file1 or from standard input, sending one copy of each line to file2 (or to standard output). Often used as a filter. Specify only one of -d or -u. See also comm and sort.
Options
Print each line once, prefixing number of instances.
Print duplicate lines once but no unique lines.
Print all duplicate lines. -D takes no delimiter method. The delimiter method method takes one of the following values: none (default), prepend, or separate. Blank lines are used as the delimiter.
Ignore first n fields of a line. Fields are separated by spaces or by tabs.
Ignore case differences when checking for duplicates.
Ignore first n characters of a field.
Print only unique lines (no copy of duplicate entries is kept).
Compare only first n characters per line (beginning after skipped fields and characters).
Print a help message and then exit.
Print version information and then exit.
Examples
Send one copy of each line from list to output file list.new:
uniq list list.new
Show which names appear more than once:
sort names | uniq -d




