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 8942831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:37:08+00:00 2026-06-15T11:37:08+00:00

Suppose I have a reference list, say file1.txt , which contains: a b c

  • 0

Suppose I have a reference list, say file1.txt, which contains:

a
b
c 
d

and I have file2.txt, the data file as follows:

a 1 2 3
b 5 6 7
d 6 7 8
e 7 8 9

and output needed in output.txt:

a 1 2 3
b 5 6 7
d 6 7 8

I want to match IDs in file1.txt with first column of file2.txt and print the whole line (row from file2.txt) into output.txt

  • 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-15T11:37:10+00:00Added an answer on June 15, 2026 at 11:37 am
    awk 'FNR==NR{a[$1];next}($1 in a)' file1.txt file2.txt
    

    Also in perl :

    perl -F -lane '$h{$F[0]}++;if($h{$F[0]}>=2){print $_;}' file1 file2
    

    Note:The above perl command will work provided the first file has unique ID’s

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

Sidebar

Related Questions

Suppose I have a weak reference to a car which has an ordinary (strong)
Quick question... Suppose I have a C# struct that contains a single reference member.
Suppose I have three projects in my sln. (1) xyz.a{Class Lib}{no reference added} (2)
Suppose I have a large list of words. For an example: >>> with open('/usr/share/dict/words')
I'm using Protobuf-net. Suppose I have a list of Gizmo objects serialized and that
Suppose we have a subroutine returning a reference sub aspirin { my @items =
I'm using .NET C# for a project. I have a list of products which
Ok, we have a 'pseudo-c#' file that we've added to the solution for reference.
Suppose I have a factory method, which wants to construct an instance of a
I have an algorithmic problem which can be reduced to this task: Suppose we

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.