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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:13:11+00:00 2026-06-04T05:13:11+00:00

I am many (3 just an example) text files in different directories (3 different

  • 0

I am many (3 just an example) text files in different directories (3 different names) like following:

Directory: A, file name: run.txt format: txt tab deliminated

; file one 
10     0.2   0.5   0.3
20     0.1   0.6   0.8
30     0.2   0.1   0.1
40     0.1   0.5   0.3

Directory: B, file name: run.txt format: txt tab deliminated

; file two 
10     0.2   0.1   0.2
30     0.1   0.6   0.8
50     0.2   0.1   0.1
70     0.3   0.4   0.4

Directory: C, file name: run.txt format: txt tab deliminated

; file three 
10     0.3   0.3   0.3
20     0.3   0.6   0.8
30     0.1   0.1   0.1
40     0.2   0.2   0.3

I want to combine all three run.txt files into single and renumber the first column. The resulting new file will look like:

; file combined 
10     0.2   0.5   0.3
20     0.1   0.6   0.8
30     0.2   0.1   0.1
40     0.1   0.5   0.3

50     0.2   0.1   0.2
70     0.1   0.6   0.8
90     0.2   0.1   0.1
110    0.3   0.4   0.4

120    0.3   0.3   0.3
130    0.3   0.6   0.8
140    0.1   0.1   0.1
150    0.2   0.2   0.3

This what my codes are at:

cat A/run.txt B/run.txt C/run.txt > combined.txt

(1) I do not know how to take care of renumbering by first column

(2) Also I do not how to take care of comment starting with “;”

Edit:

Let me be clear about the number scheme:
A/run.txt, B/run.txt and C/run.txt are actually parallel run to combined into one.
so each will have stored samples with run number. However gap can be uneven among the run.

(1) for first file A/run.txt (gap is 10, 20-10, 30-20)

10, 10+10, 20+10, 30+10

(2) for second file B/run.txt, starts from 10 but has gap of 20
(eg. 30-10, 50-70, 70-50)

40 (from last line of the first file) + 10 (first in file two) = 50, 
 50 + 20 = 70,70 + 20 = 90,  90+ 20 = 110

(3) file C/run.txt starts from 10 and increment is 10

110 (last number in file 2) + 10 = 120, 120+ 10 = 130,
 130+10 = 140, 140+10 = 150`
  • 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-04T05:13:13+00:00Added an answer on June 4, 2026 at 5:13 am
    #!/usr/bin/awk -f
    BEGIN {
        OFS = "\t"
        printf "%s\n", "; file combined"
    }
    ! /^;/ {
        if (FILENAME != prevfile) {
            prevnum = $1
            prevfile = FILENAME
            interval = 10
            c = 0
        }
        c++
        if (c == 2) {
            interval = $1 - prevnum
        }
        $1 = (i += interval)
        print
    }
    

    To run it:

    $ ./renumber {A,B,C}/run.txt
    

    Given your sample input, it produces output that exactly matches your sample.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text file(test.data), which include some values and class name, for example 4.5,3.5,U1
Just like stackoverflow, there is a many-to-many relationship between Question and Tag. After running
I'm just playing around with PivotViewer control in Silverlight 5. It seems like many
I just found the post Adobe Forums: Simple Text String Example in specification broken.
I'd like to extract the text from an HTML file using Python. I want
Was just wondering how do these sites (and many other softwares that generate flash
I've just gone blank. I have a many to many relationship with three tables.
I have MANY small Test Projects where I put together just enough code to
I'm just wondering if anyone has had any problems having too many subscribers for
Many times when I lose connection to my development server, I just log back

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.