UNIQ(1)

๐Ÿ’– UNIQ(1) โ€” the uniq girlies' guide ๐Ÿ’–

okay so bestie, welcome to uniq, from the User Commands chapter. she's a little filter with big main character energy and she's about to change your whole text-processing life. no cap. โœจ


๐ŸŒธ NAME ๐ŸŒธ

uniq โ€” report or omit repeated lines. that's it. that's the vibe. she looks at your lines, notices when the same one shows up again right after itself, and decides what to do about it. iconic behaviour honestly. ๐Ÿ’…


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

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

โœจ DESCRIPTION โœจ

she filters adjacent matching lines from INPUT (or standard input if you don't give her one), and writes the result to OUTPUT (or standard output). simple as that, fr fr. ๐Ÿซถ

with no options, matching lines get merged down to the first occurrence. so if you feed her the same line three times in a row, you get it back once. slay.

mandatory arguments to long options are mandatory for short options too. yes, that means what you think it means โ€” if a long option needs a value, the short version needs it too. don't try to be cute about it. ๐Ÿ™ˆ

here come the options, and there are a lot of them, so buckle up buttercup:

  • -c, --count โ€” prefixes each line with the number of times it occurred. so you can see how many times the group showed up. obsessed. ๐Ÿ”ฅ
  • -d, --repeated โ€” only prints the duplicate lines, one per group. she's showing you the repeats and nothing else. ๐Ÿ’€
  • -D โ€” prints all the duplicate lines. like, every single one of them, not just one per group. all gas no brakes. ๐ŸŒˆ
  • --all-repeated[=METHOD] โ€” basically -D but you get to separate the groups with an empty line. METHOD can be none (that's the default), prepend, or separate. โœจ
  • -f, --skip-fields=N โ€” don't compare the first N fields. just skip right past them like they don't exist. ๐Ÿ’…
  • --group[=METHOD] โ€” shows you all the items, separating the groups with an empty line. METHOD is separate (the default), prepend, append, or both. ๐ŸŒธ
  • -i, --ignore-case โ€” ignores case differences when comparing. she's not gonna be weird about uppercase vs lowercase. ๐ŸŽ€
  • -s, --skip-chars=N โ€” don't compare the first N characters. โœ‚๏ธ
  • -u, --unique โ€” only prints the unique lines. the ones that showed up exactly once. the rare ones. the special ones. ๐Ÿ’œ
  • -z, --zero-terminated โ€” the line delimiter is NUL, not newline. for when your data is built different. ๐Ÿงš
  • -w, --check-chars=N โ€” compares no more than N characters in each line. โœจ
  • --help โ€” displays this help and exits. ๐Ÿซถ
  • --version โ€” outputs version information and exits. โญ

๐ŸŒผ the field lore ๐ŸŒผ

a field is a run of blanks (usually spaces and/or TABs), then non-blank characters. and important: fields are skipped before chars. so the order matters, bestie. ๐Ÿ“


โš ๏ธ THE BIG WARNING, PAY ATTENTION: uniq does not detect repeated lines unless they are adjacent. like, she has no memory of what came before โ€” only what's right next to each other. so you may want to sort the input first, or just use sort -u without uniq at all. ๐Ÿ’€ this is THE thing people get wrong. don't be that person. i'm begging. ๐Ÿ˜ญ

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

written by Richard M. Stallman and David MacKenzie. legends. periodt. ๐Ÿซถ


๐Ÿ› REPORTING BUGS ๐Ÿ›


Copyright ยฉ 2026 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.

this is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law. (say it with me. no warranty. none. zero. ๐Ÿ™ˆ)

๐Ÿ” SEE ALSO ๐Ÿ”


okay that's the whole page, you made it, i'm so proud of you ๐Ÿฅน this was GNU coreutils 9.12, dated September 2026 โ€” and that's the tea, bestie. go sort your files and slay. ๐Ÿ’–๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from