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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:23:06+00:00 2026-06-05T22:23:06+00:00

I have a text file (tab separated) which consist of 17 column. I would

  • 0

I have a text file (tab separated) which consist of 17 column. I would like to change this structure in this way. Conserve column from 1 to 6, until the end of the file of course, and append column from 7 to 16 (I can get rid of the 17) one below each other and so repeat every the ones from 1 to 5 for each column that I added. This means that I will also need to add an extra column with same numbers until the next added start, in order to keep track of the column that I appended and see at which line it start.

Hope this is enough clear.

Thanks for yours precious time and support.

Original

179    1   AA     19.50    30.00  1.0000  2.0000  3.0000 ...  
180    1   BB     19.75    30.00  4.0000  5.0000  6.0000 ...  
230    1   CC     32.25    30.00  7.0000  8.0000  9.0000 ...  

Needed

179    1  1 AA     19.50     30.00  1.0000    
180    1  1 BB     19.75     30.00  4.0000    
230    1  1 CC     32.25     30.00  7.0000  
179    1  2 AA     19.50     30.00  2.0000   
180    1  2 BB     19.75     30.00  5.0000    
230    1  2 CC     32.25     30.00  8.0000   
179    1  3 AA     19.50     30.00  3.0000    
180    1  3 BB     19.75     30.00  6.0000    
230    1  3 CC     32.25     30.00  9.0000   
  • 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-05T22:23:07+00:00Added an answer on June 5, 2026 at 10:23 pm

    How about this for an idea (using awk to pick out the column data, using temporary output files to hold the data):

    rearrange.awk:

    {
       for (i=6; i<=NF; ++i) {
          print $1, $2, (i-5), $3, $4, $5, $i > "temp_output"i".txt"
       }
    }
    

    Then this would be used in a script:

    awk -f rearrange.awk < input.txt
    cat temp_output*.txt > output.txt
    rm temp_output*.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file which is tab separated. They can be quite big
I have text file with some stuff that i would like to put into
I have text file, like FILED AS OF DATE: 20090209 DATE AS OF CHANGE:
I have a tab separated text file after executing some command in powershell i
I have a tab separated text file in the format id | field 1
I have a simple tab-separated text file that I want Ruby to read every
I have a text file that is tab-delimited. How can I separate this string
I would like to store values in a text file as comma or tab
I have a text file (bowtie alignment file) that looks like this: read_1 +
I have a text file having numbers like this +12345678912 (start with + and

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.