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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:13:39+00:00 2026-05-23T01:13:39+00:00

So I have a first file with a ID in each line, for example:

  • 0

So I have a first file with a ID in each line, for example:

458-12-345
466-44-3-223
578-4-58-1
599-478
854-52658
955-12-32

Then I have a second file. It has a ID in each file followed by information, for example:

111-2457-1 0.2545 0.5484 0.6914 0.4222
112-4844-487 0.7475 0.4749 0.1114 0.8413
115-44-48-5 0.4464 0.8894 0.1140 0.1044

….

The first file only has 1000 lines, with the IDs of the info I need, while the second file has more than 200,000 lines.

I used the following bash command in a fedora with good results:

cat file1.txt | while read line; do cat file2.txt | egrep "^$line\ "; done > file3.txt

However I’m now trying to replicate the results in Ubuntu, and the output is a blank file. Is there a reason for this not to work in Ubuntu?

Thanks!

  • 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-05-23T01:13:39+00:00Added an answer on May 23, 2026 at 1:13 am

    Typical job for awk:

    awk 'FNR==NR{i[$1]=1;next} i[$1]{print}' file1 file2
    

    This will print the lines from the second file that have an index in the first one. For even more speed, use mawk.

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

Sidebar

Related Questions

I have text file with something like first line line nr 2 line three
I have a file, in which each line contains several words that are separated
I have a text file where each line is a list of arguments I
I have a txt file with 16 lines of integers. Each line contains 5
I have two csv file. First File has date offerid clicks orders Second File
hi guys i have two pipe delimited files,first file contains 1000 records and second
I have 3 files 1) show_createtable.html 2) do_showfielddef.php 3) do_showtble.php 1) First file is
Suppose I have two XML files. First XML File: <?xml version=1.0?> <AccessRequest xml:lang=en-US> <AccessLicenseNumber>Your_License</AccessLicenseNumber>
First I have a PHP file that gets data and file from a HTML
I have the following style in an external CSS file called first.css table {

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.