Skip to content
Advertisement

Combining values from different files into one CSV file

I have a couple of files containing a value in each line.

EDIT :

I figured out the answer to this question while in the midst of writing the post and didn’t realize I had posted it by mistake in its incomplete state.

I was trying to do:

paste -d ',' file1 file2 file 3 file 4 > file5.csv

and was getting a weird output. I later realized that was happening because some files had both a carriage return and a newline character at the end of the line while others had only the newline character. I got to always remember to pay attention to those things. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­

Advertisement

Answer

file 1:

1
2
3

file2:

2
4
6
paste --delimiters=; file1 file2

Will yield:

1;2
3;4
5;6
Advertisement