Uniq (COMP2041)

uniq is a unix command-line tool that takes a text file and outputs all identical adjacent lines as one line.

It takes input in the format

uniq <file>

It's commonly sorted first, so that the duplicate lines are adjacent.


  • -c = each line starts with a count of how many duplicates their were
  • -d = only outputs lines that were duplicated
  • -u = only outputs lines that were unique
  • -i = ignore case differences
  • -f = ignore certain fields
  • -w = only compare n characters