1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 00:54:57 +00:00
serenity/Base/usr/share/man/man1/uniq.md
Tim Ledbetter 8f253a745e Base: Update man pages for utilities
Man pages for utilities now more closely resemble ArgsParser output
2023-04-01 11:49:57 +01:00

1.4 KiB

Name

uniq - filter out repeated adjacent lines

Synopsis

$ uniq [-c] [-d|-u] [-f skip-fields] [-s skip-chars] [--version] [INPUT] [OUTPUT]

Description

Filter out repeated adjacent lines from INPUT (or standard input) and write to OUTPUT (or standard output). It is recommended to sort out the input using sort(1) beforehand.

Options

  • -c, --count: Precede each line with its number of occurrences.
  • -d, --repeated: Only print repeated lines.
  • -u, --unique: Only print unique lines (default).
  • -i, --ignore-case: Ignore case when comparing lines.
  • -f N, --skip-fields N: Skip first N fields of each line before comparing.
  • -s N, --skip-chars N: Skip first N chars of each line before comparing.
  • --help: Display help message and exit.
  • --version: Print version.

Examples

Filter out repeated lines from README.md and write to standard output:

$ uniq README.md

Filter out repeated lines from README.md and write to UNIQUE.md:

$ uniq README.md UNIQUE.md

Filter out repeated lines from standard input with their occurrence count:

$ echo "Well\nWell\nWell\nHello Friends!" | uniq -c
3 Well
1 Hello Friends!

Filter out repeated lines, ignoring the first field ("XXXX" and "ZZZZ") and the four chars after it (" ABC" and " BCA", thus comparing only the "D"s — which are equal indeed):

$ echo "XXXX ABCD\nZZZZ BCAD" | uniq -f1 -s4
ZZZZ BCAD