Hi everyone,
I have two files, namely:
file1:
file1Col1Row1;file1Col2Row1;file1Col3Row1
file1Col1Row2;file1Col2Row2;file1Col3Row2
file1Col1Row3;file1Col2Row3;file1Col3Row3
file2:
file2Col1Row1;file2Col2Row1;file2Col3Row1
file2Col1Row2;file2Col2Row2;file2Col3Row2
file2Col1Row3;file2Col2Row3;file2Col3Row3
I need to concatenate both files line by line so that the output will be:
file1Col1Row1;file1Col2Row1;file1Col3Row1;file2Col1Row1;file2Col2Row1;file2Col3Row1
file1Col1Row2;file1Col2Row2;file1Col3Row2;file2Col1Row2;file2Col2Row2;file2Col3Row2
file1Col1Row3;file1Col2Row3;file1Col3Row3;file2Col1Row3;file2Col2Row3;file2Col3Row3
The only way I can think of is using 2 nested while
loops that read from each file and output to another file, but I don't know if there's a more efficient way?
Any ideas will be more than welcome. Thanks in advance.
---------- Post updated at 07:18 PM ---------- Previous update was at 07:02 PM ----------
I found the answer:
gacanepa@Gabriel-PC ~/stuff/scripts/bash $ cat file1
file1Col1Row1;file1Col2Row1;file1Col3Row1
file1Col1Row2;file1Col2Row2;file1Col3Row2
file1Col1Row3;file1Col2Row3;file1Col3Row3
gacanepa@Gabriel-PC ~/stuff/scripts/bash $ cat file2
file2Col1Row1;file2Col2Row1;file2Col3Row1
file2Col1Row2;file2Col2Row2;file2Col3Row2
file2Col1Row3;file2Col2Row3;file2Col3Row3
gacanepa@Gabriel-PC ~/stuff/scripts/bash $ paste -d";" file1 file2
file1Col1Row1;file1Col2Row1;file1Col3Row1;file2Col1Row1;file2Col2Row1;file2Col3Row1
file1Col1Row2;file1Col2Row2;file1Col3Row2;file2Col1Row2;file2Col2Row2;file2Col3Row2
file1Col1Row3;file1Col2Row3;file1Col3Row3;file2Col1Row3;file2Col2Row3;file2Col3Row3
---------- Post updated at 07:20 PM ---------- Previous update was at 07:18 PM ----------
I need the help of a moderator here to mark this thread as solved. I believe I can't do it since I found the answer before any one replied to the post.