UNIQ(1)

πŸ“¦ version 1.053, in alpine 3.24

πŸ’– UNIQ(1) β€” the Perl one, bestie πŸ’–

okay so this is uniq, a User Contributed Perl Documentation page, and honestly? it's giving "tiny tool, huge main character energy." it dedupes adjacent lines and that's the whole vibe. let's get into it 🫢


✨ NAME ✨

uniq β€” report or filter out repeated lines in a file


🌸 SYNOPSIS 🌸

uniq [-c | -d | -u] [-f fields] [-s chars]
     [input_file [output_file]]

πŸ¦‹ DESCRIPTION πŸ¦‹

ok so here's the whole thing: uniq reads standard input, compares adjacent lines, and writes a copy of each unique input line to standard output. the second and succeeding copies of identical adjacent input lines? not written. gone. not invited to the group chat πŸ’…

⚠️ real talk: repeated lines that are not adjacent will not be detected. so if your dupes are scattered all over, you may need to sort the files first. iykyk 😭

here are the options that are available:

  • -c β€” precede each output line with the count of the number of times the line occurred in the input, followed by a single space. slay, now you know how popular each line was πŸ”₯
  • -d β€” don't output lines that are not repeated in the input. so you only see the ones with duplicates. iconic filtering ✨
  • -f fields β€” ignore the first fields in each input line when doing comparisons. a field is a string of non-blank characters separated from adjacent fields by blanks. field numbers are one based, i.e. the first field is field one. no cap, one-based is real πŸŽ€
  • -s chars β€” ignore the first chars characters in each input line when doing comparisons. and if you specify it in conjunction with the -f option, the first chars characters after the first fields fields will be ignored. character numbers are one based too, i.e. the first character is character one πŸ’œ
  • -u β€” don't output lines that are repeated in the input. the opposite of -d, we stan a duo 🌈

and if additional arguments are specified on the command line, they are used as the names of input files. simple as that 🧚

the uniq utility exits 0 on success or >0 if an error occurred. she tells you when something's wrong, we love an honest queen πŸ‘‘


⭐ COMPATIBILITY ⭐

the historic -number and +number options are supported as synonyms for -f fields and -s chars, respectively. retro but make it fashion πŸ’…

this version accepts 0 as a valid argument for the -f and -s switches β€” some implementations of uniq do not. so yeah, we're the chill one 🫢


πŸ‘€ SEE ALSO πŸ‘€

  • sort(1) β€” the bestie you call when your dupes aren't adjacent, fr fr

πŸ’€ BUGS πŸ’€

uniq has no known bugs. not me being flawless πŸ˜ŒπŸ’… periodt.


🌟 AUTHOR 🌟

the Perl implementation of uniq was written by Jonathan Feinberg, jdf@pobox.com. ty bestie for your service πŸ«‘πŸ’–


this program is copyright (c) Jonathan Feinberg 1999.

this program is free and open software. you may use, modify, distribute, and sell this program (and any modified variants) in any way you wish, provided you do not restrict others from doing the same. that's the whole license, no fine print, we love to see it βœ¨πŸŽ€


that's the whole page bestie, go forth and dedupe πŸ¦‹

cute little sign-off: this was perl v5.42.2, dated 2026-02-15 β€” mwah, bye πŸ’œ

πŸ“¦ where this page comes from