Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

110
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda