uniq
uniq [OPCIÓN]... [ENTRADA [SALIDA]]
Reportar u omitir líneas repetidas.
Options
--all-repeated=<delimit-method>,-D <delimit-method>-
mostrar todas las líneas duplicadas. La delimitación se hace con líneas en blanco. [por defecto: none]
--group=<group-method>-
mostrar todos los elementos, separando grupos con una línea vacía. [por defecto: separate]
--check-chars=<N>,-w <N>-
comparar no más de N caracteres en las líneas
--count,-c-
prefijar líneas por el número de ocurrencias
--ignore-case,-i-
ignorar diferencias de mayúsculas al comparar
--repeated,-d-
solo mostrar líneas duplicadas
--skip-chars=<N>,-s <N>-
evitar comparar los primeros N caracteres
--skip-fields=<N>,-f <N>-
evitar comparar los primeros N campos
--unique,-u-
solo mostrar líneas únicas
--zero-terminated,-z-
terminar líneas con byte 0, no nueva línea
Filtrar líneas coincidentes adyacentes de ENTRADA (o entrada estándar), escribiendo a SALIDA (o salida estándar).
Nota: uniq no detecta líneas repetidas a menos que sean adyacentes. Puede que quiera ordenar la entrada primero, o usar sort -u sin uniq.
Examples
Display each line once:
sort {{path/to/file}} | uniq
Display only unique lines:
sort {{path/to/file}} | uniq {{[-u|--unique]}}
Display only duplicate lines:
sort {{path/to/file}} | uniq {{[-d|--repeated]}}
Display number of occurrences of each line along with that line:
sort {{path/to/file}} | uniq {{[-c|--count]}}
Display number of occurrences of each line, sorted by the most frequent:
sort {{path/to/file}} | uniq {{[-c|--count]}} | sort {{[-nr|--numeric-sort --reverse]}}
Compare only the first 10 characters on each line for uniqueness:
sort {{path/to/file}} | uniq {{[-w|--check-chars]}} 10
Compare text after the first 5 characters on each line for uniqueness:
sort {{path/to/file}} | uniq {{[-s|--skip-chars]}} 5
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.