Question: (Closed) Merging File
gravatar for prt-hntr
5.1 years ago by
New Delhi
prt-hntr10 wrote:

I have two files like file1.dat and file2.dat I would like to combine the file without changing the format of file1 and file2. file1(2space)file2.

for example File1:

    1 2 3  4 5             
    6 7 8  8 9


      8 6 4258
      8 5 9927

The result i want is

                         1 2 3 4 5(2space)8 6 4258
                         6 7 8 8 9(2space)8 5 9927

I have tried with paste -d ' ' file1 and file2 but got only one space between the file. I have 5 column and thousand of rows in files.

thank you in advance


ADD COMMENTlink modified 5.1 years ago by Dalia30 • written 5.1 years ago by prt-hntr10

This is a simple programming problem and not bioinformatics related (remains so, even if the files contain some biological data). Closing because solved elsewhere. A possible solution based on join is (like a relational database join, using content of certain columns) presented here:

or here, if it is just about joining row by row:

ADD REPLYlink modified 5.1 years ago • written 5.1 years ago by Michael Dondrup45k
gravatar for Dalia
5.1 years ago by
Rochester, NY
Dalia30 wrote:

this is probably not the best solution bc it involves 2 steps but a quick one if you are in a hurry:

paste -d '\t' file1 file2 >file3

this will place a tab between the two files and save in file3 Then you can substitute the tab for two spaces in file3:

sed 's/\t/ /g' file3

(with two spaces between the / /)

there is definitely a more direct way to do this

good luck!

a caveat: this will replace ALL tabs in your file. You want to make sure there aren't any other tabs.

ADD COMMENTlink modified 5.1 years ago • written 5.1 years ago by Dalia30
Please log in to add an answer.
The thread is closed. No new answers may be added.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1930 users visited in the last hour