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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:49:00+00:00 2026-05-28T02:49:00+00:00

Infile1: 1 a 3 c 4 d 6 f Infile2: 1 a 2 b

  • 0

Infile1:

1 a
3 c
4 d
6 f

Infile2:

1 a 
2 b
5 e
6 f
7 g
8 h

How do I join these files with the unix join command to get this output:

1 aa
2 b
3 c
4 d
5 e
6 ff
7 g 
8 h

Dogbanes answer worked but…
when I apply dogbanes answer on this file:

27  27
28  22
29  37
30  15
31  21
32  13
33  18
34  24

and this:

27  7
28  13
29  6
30  12
31  30
32  5
33  10
34  28

They don’t join:

27  27
27  7
28  13
28  22
29  37
29  6
30  12
30  15
31  21
31  30
32  13
32  5
33  10
33  18
34  24
34  28

The second scenario is tab delimited so I used -t \t

  • 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-28T02:49:01+00:00Added an answer on May 28, 2026 at 2:49 am

    First sort both files. Then use join to join on the first field of both files. You also need to pipe the output through sed if you want to remove the space and thus convert a a into aa. This is shown below:

    $ join -t " " -1 1 -2 1 -a 1 -a 2  <(sort file1) <(sort file2) | sed 's/ \([a-z]\) / \1/g'
    1 aa
    2 b
    3 c
    4 d
    5 e
    6 ff
    7 g
    8 h
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to split a file into multiple files without compression. I found this
I am sorry if this is a silly question but I have been working
This is the code I have, but the file is a little smaller and
Why do I get an extra iteration (extra line printed) when this code completes?
i'm working on a simple loop but it's not working. I have 2 files
I'm following this tutorial CSV-FILE-EXPORT-IMPORT-RAILS but something im doing wrong, because i got an
My scenario I'm using django-storage to have the files served via Amazon S3. This
I'm ok at basic MySQL, but this is WAY OVER MY HEAD! Objectives: Import
import os listing = os.listdir(path) for infile in listing: print infile f = open(os.path.join(path,
When using LOAD DATA INFILE, is there a way to get the same functionality

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.