Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!