Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
Using uniq to compare 2 dictionaries

So I have two dictionaries to compare (american english vs british english).

How do I use the uniq command to count (-c) how many words are in the american english or british english but not both?

Also how do I count the number of word occurrences of one dictionary that appears in a different dictionary?

Just trying to understand how uniq works on a more complicated level. Any help is appreciated!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Instead of uniq, use the comm command for this. It finds lines that are in common between two files, or are unique to one or the other.

This counts all the words that are in one dictionary but not both

comm -3 american british | wc -l

This counts the words that are in both dictionaries:

comm -12 american british | wc -l

By default, comm shows the lines that are only in the first file in column 1, the lines that are only in the second file in column 2, and the lines in both files in column 3. You can then use the -[123] options to tell it to leave out the specified columns. So -3 only shows columns 1 and 2 (the unique words in each file), while -12 only shows column 3 (the common words).

It requires that the files be sorted, which I assume your dictionary files are.

You can also do it with unique. It has options -u to show only lines that appear once, and -d to show only lines that are repeated.

sort american british | uniq -u | wc -l # words in just one language
sort american british | uniq -d | wc -l # words in both languages
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda