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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:56:28+00:00 2026-06-03T21:56:28+00:00

I am new to bash scripting and would like to write a bash script

  • 0

I am new to bash scripting and would like to write a bash script to do the following.
I have two tab delimited files as follows:

# file1 #
## position id 
.
.
.


# file2
## position type
. 
.
.

file 2 is a subset of file 1 with regard to the position column.
I want to generate file3 such that for every line in file2, it looks up the line with the same position in file1 and writes out the following into file3

position id type
.
.
.

So, I want to essentially find the common positions between file1 and file2 (first column) and write them out along with their id and types (column 2 in the respective files).
I know how to do this using python but I would like to learn how to do a procedure like this using a bash script – i would appreciate any example code for the above problem.

Extra note:

The values in each column are as follows

  • position: chr1:887799
  • id: R2A
  • type: analphabeticstring

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-06-03T21:56:30+00:00Added an answer on June 3, 2026 at 9:56 pm
    join -a 1 <(sort file1) <(sort file2)
    

    Should get you there

    The man page of join has more background and samples:

    • http://linux.die.net/man/1/join
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm quiet new to bash scripting, and I would like to convert recursively all
I am very new to Bash scripting. I am trying to write a script
I'm new to bash scripting so would need your help. I am trying to
I'm rather new to bash scripting, and Google isn't as useful as I'd like
FILE: hello world I would like to use a scripting language ( BASH )
I am new to bash. I need to write the script which executes the
New to bash scripting, I'm writing a script to copy my TV shows accross
Hello im new to bash scripting, i have a simple program which is not
I am new to bash scripting and trying to learn a few things. Here
I'm creating a bash script to create new EC2 instances and then upload a

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.