Merge multiple text files with different length

Viewed 148

I have multiple files with simple format like

File1   File2   File3
|1|     |2|     |4|
        |3|     |5|
                |6|

All files have different length. I try to get the following output:

|1,2,4|
|,3,5 |
|,,6  |

So each row of the output contains each row of the equivalent input files with a comma as delimiter.

Running the following command

paste -d',' input1 input2

for two input files gives the suitable output above. However, running the command for three input files results in

|1,2|
|,4 |
|,3 |
|,5 |
...

Why does the command for two files fail with three or more files?

1 Answers
Related