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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:57:06+00:00 2026-05-25T18:57:06+00:00

I really don’t know if awk would be the appropriate tool for that task…

  • 0

I really don’t know if awk would be the appropriate tool for that task… Maybe something in python would be better. Anyway, I thought asking here first for the feasibility of the task. Here we go :

Datas :

###

offspr84 175177 200172 312312 310326 338342 252240 226210 113129 223264
male28 197175 172200 308312 310338 262338 256252 190226 113129 223219
female13 197177 172172 312308 318326 342350 240248 210218 129113 267247

###

offspr85 181177 192160 320312 290362 358330 238238 214178 133129 263223
male65 197181 176192 320268 322286 358330 238244 206214 137133 267263
female17 181177 160172 280312 362346 350326 230238 126178 129129 223167

###

So basicaly I need to print the first field ($1) and matching (in bold) $9 in the first record and matching $2 and $6 in second record.

Output file :
offspr84 113129
male28 113129

offspr85 181177
female17 181177

offspr85 358330
male65 358330

Any hint on how I could accomplish that ?

Thanx !

  • 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-25T18:57:06+00:00Added an answer on May 25, 2026 at 6:57 pm

    This code will produce the output you want. Maybe not the best way, but seems to work as expected.

    #data = [
        #'offspr84 175177 200172 312312 310326 338342 252240 226210 113129 223264',
        #'male28 197175 172200 308312 310338 262338 256252 190226 113129 223219',
        #'female13 197177 172172 312308 318326 342350 240248 210218 129113 267247']
    
    data = [
    'offspr85 181177 192160 320312 290362 358330 238238 214178 133129 263223',
    'male65 197181 176192 320268 322286 358330 238244 206214 137133 267263',
    'female17 181177 160172 280312 362346 350326 230238 126178 129129 223167' ]
    
    for i, line in enumerate(data):
        data[i] = line.split(' ')
    
    for item in data[0]:
        if data[1].count(item) > 0:
            print data[0][0], item
            print data[1][0], item
    
        if data[2].count(item) > 0:
            print data[0][0], item
            print data[2][0], item
    

    Update:

    With a nested list to include both list at once:

    datas = [[
    'offspr85 181177 192160 320312 290362 358330 238238 214178 133129 263223',
    'male65 197181 176192 320268 322286 358330 238244 206214 137133 267263',
    'female17 181177 160172 280312 362346 350326 230238 126178 129129 223167' ],
    [
    'offspr84 175177 200172 312312 310326 338342 252240 226210 113129 223264',
    'male28 197175 172200 308312 310338 262338 256252 190226 113129 223219',
    'female13 197177 172172 312308 318326 342350 240248 210218 129113 267247']
    ]
    for data in datas:
        for i, line in enumerate(data):
            data[i] = line.split(' ')
    
    
    for data in datas:
        for item in data[0]:
            if data[1].count(item) > 0:
                print data[0][0], item
                print data[1][0], item
    
            if data[2].count(item) > 0:
                print data[0][0], item
                print data[2][0], item
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is one of things that I really don't get. I know that it's
A really boring question, sorry, but I really don't know that yet ;) I've
I really don't know how to describe it, but if you understood it and
I am re-designing an application for a ASP.NET CMS that I really don't like.
I've just installed Resharper, and I really don't know how to use it correctly.
I really don't know how to say, may be this is why I didn't
I really don't know advice with validating user input. I'm begining with RoR. I
I really don't know what my problem is lately, but Regex seems to be
I really don't understand where are __str__ and __repr__ used in Python. I mean,
I have this problem and really don't know how to solve this. I'm having

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.