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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:37:42+00:00 2026-06-09T22:37:42+00:00

I am trying to extract column1 and column7 from the text files of two

  • 0

I am trying to extract column1 and column7 from the text files of two different directories. The names of files are same in these directories. I need to save the outputs to another directory.

file1.txt in D1 directory

column1  column2  column3  column7
david    45.2       14.6   45.0
grecy    12.0       0.0    12.0
anjal    23.2       321.0  34.5

file1.txt in D2 directory

column1  column2  column3  column7
david    45.2       14.6   56.0
grecy    10.0       0.0    12.0
moha     23.1       321.0  334.5

output format (save the output as file1.txt in D3 directory)

column1  column1  column7  column7
david      david    45.0   56.0
grecy      grecy    12.0   12.0
anjal      moha     34.5   334.5

Your suggestions would be appreciated.

  • 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-09T22:37:44+00:00Added an answer on June 9, 2026 at 10:37 pm

    A quick way using paste and awk:

    paste D1/file1.txt D2/file1.txt | awk '{ printf "%s\t%s\t%s\t%s\n", $1, $5, $4, $8 }' > D3/file1.txt
    

    Results:

    column1 column1 column7 column7
    david   david   45.0    56.0
    grecy   grecy   12.0    12.0
    anjal   moha    34.5    334.5
    

    EDIT: To process multiple files, you can use a bash loop:

    for i in D1/*.txt; do paste "$i" D2/${i/D1\//} | awk '{ printf "%s\t%s\t%s\t%s\n", $1, $5, $4, $8 }' > D3/${i/D1\//}; done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to extract all of the links to image files from a text
I am trying to extract columns from multiple text files(3000 files). The sample of
im trying to extract some files from a jar-file downloaded using java-webstart. below code
I'm trying to extract column names from a SQLite result set from sqlite_master's sql
I am trying to extract graph information from a text file and converting it
I'm trying to extract the number from a text string and join it to
I'm trying to extract the # of minutes from a text field using Oracle's
I am trying to extract values from an XML column. Unfortunately, whatever combination I
I'm trying to extract euler angles from a rotation matrix. My convetions: Matrix column-major,
Trying to extract files to a given folder ignoring the path in the zipfile

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.