uniq

GNU uniq Cheatsheet #

GNU uniq is a command-line utility that filters adjacent matching lines from a file.

Basic Usage #

Command/OptionExampleDescription
uniq file.txtuniq data.txtRemove duplicate lines from a file
uniq -c file.txtuniq -c data.txtPrecede each line with the number of occurrences
uniq -d file.txtuniq -d data.txtOnly print duplicate lines

Sorting #

Command/OptionExampleDescription
`sort file.txtuniq``sort data.txt
uniq -u file.txtuniq -u data.txtOnly print lines that are not repeated

Field Specific #

Command/OptionExampleDescription
uniq -f1 file.txtuniq -f1 data.txtSkip the first field when comparing lines
uniq -s5 file.txtuniq -s5 data.txtSkip the first 5 characters when comparing lines

Ignore Case #

Command/OptionExampleDescription
uniq -i file.txtuniq -i data.txtIgnore case when comparing lines

This cheatsheet provides essential GNU uniq commands for filtering duplicate lines from files.

uniq

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.