0

I have three CSV files which have the same same row count.

1.csv
1,2,3
4,5,6
7,8,9

2.csv
4
5
6

3.csv
8
9
10

After combining I want the result as

result.csv
1,2,3,4,8
4,5,6,5,9
7,8,9,6,10

So I tried with

paste 1.csv 2.csv | tr "\t" "," > intermediate.csv
paste intermediate.csv 3.csv | tr "\t" "," > result.csv

But I got result like

 result.csv
    1,2,3, 4,8
    4,5,6, 5,9
    7,8,9, 6,10
6

Try this:

paste -d, 1.csv 2.csv 3.csv > result.csv

The -d flag sets the delimiter so you don't have to attempt to clobber the tabs with tr.

Not the answer you're looking for? Browse other questions tagged or ask your own question.