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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:59:26+00:00 2026-06-12T14:59:26+00:00

In one tab-delimited file, it takes the form of: ID | integer | integer

  • 0

In one tab-delimited file, it takes the form of:

ID | integer | integer

1   12345    56789
2   11111    233323
3   43423    789798

Basically file1.txt is a tab-delimited file where the first column is the primary key of a sql database numbered 1-50. The other two columns are just numbers that correspond to our data set.

Then in another file I have:
string | integer

c1  234234
c10 2342 
c11 5234
c2  987987
c3  234234

In file2.txt , the ID is a string where the digit is the corresponding ID in file1.txt. I want to append the integer data from file2.txt to file1.txt.
I want the output to be

1   12345    56789    234234
2   11111    233323   987987
3   43423    789798   234234

Because of the way the data was originally created in the file2 database, the string is the ID. So when we order it, it’s c1,c10,c11,c12…c2,c20,c21,c22…. etc. I want to line up the numbers with the first file and append the data. How can I do this? I’m pretty noob to bash and only found the paste command if my columns already lined up perfectly. 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-12T14:59:29+00:00Added an answer on June 12, 2026 at 2:59 pm

    One way using GNU awk:

    awk 'BEGIN { FS=OFS="\t" } FNR==NR { array[substr($1, 2)]=$2; next } { if ($1 in array) print $0, array[$1] }' file2.txt file1.txt
    

    Results:

    1   12345   56789   234234
    2   11111   233323  987987
    3   43423   789798  234234
    

    Edit:

    Perhaps the string in file2.txt could contain many non-digit characters. If this is the case, then try the following:

    awk 'BEGIN { FS=OFS="\t" } FNR==NR { gsub(/[^0-9]+/, "", $1); array[$1]=$2; next } { if ($1 in array) print $0, array[$1] }' file2.txt file1.txt
    

    Results:

    1   12345   56789   234234
    2   11111   233323  987987
    3   43423   789798  234234
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tab delimited file (one line). I can easily enough replace the
I'm trying to read this tab-delimited file into pandas with one caveat: the last
I'm trying to import a tab-delimited file into my PostgreSQL database. One of the
I have a workbook that has many checkboxes (form control) on one tab. I
$lineArray = preg_split('/\t\s*(?=([^]*[^]*)*[^]*$)/', $line); Above code snippet it to split a tab delimited file
I have a tab delimited file with 5 columns and need to retrieve a
I have to parse a tab-delimited text file with Ruby to extract some data
I read in a text file that is tab delimited, i then have a
I'm looking at my delimited-file (e.g. CSV, tab seperated, etc.) parsing options based on
In general I know how to import tab delimited file or comma delimited file.

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.