merge TSV files together in command line

8.4k Views Asked by At

I have 2 TSV files: file 1 has columns A, B, C file 2 has columns D

I want to merge them to get file 3 (TSV) which has columns A,B,C,D

I tried doing paste -d, file1 file2 > file3 but after they merge, columns C,D are combined into one column separated by a comma.

Help appreciated. Thanks.

2

There are 2 best solutions below

0
On BEST ANSWER

You're forcing the delimiter to be comma. Just remove -d,, by default the delimiter is tab.

1
On

From my situation, the paste command didn't work on linux system [ubuntu16.04], not know why. but using this command is ok [pure python code]:

open('newfile.tsv', 'w').write(open('f1.tsv').read() + open('f2.tsv').read())