Cheatsheets
HomeWriteupsResourcesCheatsheets
Linux
Linux
  • Know Yourself and Your System
    • id
    • logname
    • uname
    • w
    • who
    • whoami
  • Surfing / Knowing Your File System
    • cd
    • df
    • du
    • ls
    • pwd
    • stat
    • tree
  • Knowing About Files / Commands
    • alias
    • file
    • info
    • whatis
    • apropos
    • man
    • help
    • history
    • script
  • Manipulating Files / Directories
    • touch
    • mkdir
    • rm
    • rmdir
    • cp
    • mv
    • ln
  • Interacting with Files
    • cat
    • head
    • less
    • middle
    • more
    • tail
  • STROPS / Text Manipulation
    • awk
    • cut
    • grep
    • jq
    • join
    • paste
    • sed
    • sort
    • tr
    • uniq
    • xargs
    • xclip
    • wc
    • tee
    • echo
    • comm
    • diff
    • patch
    • aspell
    • Combos
  • Formatting the Output
    • nl
    • fold
    • fmt
    • pr
    • printf
  • Searching / Finding
    • find
    • locate
    • which
    • whereis
    • type
  • Web Interaction
    • curl
    • wget
  • xxd
  • References
Powered by GitBook
On this page
  • Introduction
  • Syntax
  • Important Flags
  • Examples

Was this helpful?

  1. STROPS / Text Manipulation

uniq

uniq linux command cheatsheet by Thamizhiniyan C S

Introduction

Unique command filters the output (from either a file or stdin) to remove any duplicates.


Syntax

uniq [OPTION]... [INPUT [OUTPUT]]


Important Flags

Flags
Description

-c

To count the occurrences of every line in file or stdin

-d

Will only print the lines that are repeated, not the one which are unique

-u

Will only print lines that are already uniq

-i

Ignores case(Default is case-sensitive)


Examples

Command
Description

Remove the consecutive repetitions of any line

Count the occurrences of consecutive identical lines in the input, then cut out the first six characters (presumably to remove the counts added by uniq -c), leaving only the original content of the lines

Count the occurrences of consecutive identical lines while ignoring case differences and then remove the count information, leaving only the original content of the lines

Print only the lines that occur exactly once in the input, discarding any duplicate lines.

PrevioustrNextxargs

Last updated 1 year ago

Was this helpful?

uniq
uniq -c | cut -c 7-
uniq -c -i | cut -c 7-
uniq -u