Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9245323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:14:33+00:00 2026-06-18T09:14:33+00:00

Having two files written in the form of associative array (key=value) like: file A:

  • 0

Having two files written in the form of associative array (key=value) like:

file A:

banana=yellow
kiwi=green
tomato=red

file B:

banana=dislike
tomato=like
pear=like

I would like to know the best approach (in term of speed) to compare their keys:

A against B:

kiwi=green

B against A

pear=like

bidirectional

kiwi=green
pear=like

I would prefer not to use loops as those files can be huge.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:14:34+00:00Added an answer on June 18, 2026 at 9:14 am

    B against A

    awk -F'=' 'NR==FNR{a[$1]=$0;next}!($1 in a)' A B
    

    A against B

    awk -F'=' 'NR==FNR{a[$1]=$0;next}!($1 in a)' B A
    

    bidirectional

    awk -F'=' '{a[$1]++;v[$1]=$0}END{for(i in a)if(a[i]==1)print v[i]}' A B
    

    all not tested, let me know if it doesn’t work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im my web page having file upload option..it has to check two conditions. 1)whether
I having two arrays say, $array1 = array(code => E0089, desc => some description);
I am having trouble compiling a program I have written. I have two different
I'm having trouble incorporating pyPDF logic to merge two pdf files into my django
I am having two different application configuration files in my project. I need to
I've written a PHP script that takes in two CSV files, processes them and
Having two forms, each in it's own jQuery UI tab, how can I post
I am having two forms, 1st is form_1 and 2nd is form_2. form_1 containing
I am having two coordinate points on Google map. I calculated the distance between
We are having two load balancing server. In that we have hosted a asp.net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.