views:

390

answers:

5

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

EDIT: Oops... 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. Gotta always remember to pay attention to those things =P

Also, thanks to everyone who attempted to answer the question with so little information.

A: 

you probably need to clarify or retag your question but as it stands the answer is below.

joining two files under Linux

cat filetwo >> fileone
sparkes
+1  A: 

file 1:

1
2
3

file2:

2
4
6

paste --delimiters=\; file1 file2

Will yield:

1;2
3;4
5;6
Bjorn Reppen
+1  A: 

I have a feeling you haven't finished typing your question yet, but I'll give it a shot still. ;)

file1:  file2:  file3:
1       a       A
2       b       B
3       c       C

~$ paste file{1,2,3} |sed 's/^\|$/"/g; s/\t/","/g'
"1","a","A"
"2","b","B"
"3","c","C"

Or,

~$ paste --delimiter , file{1,2,3}
1,a,A
2,b,B
3,c,C
wilhelmtell
A: 

Also don't forget about the ever versatile LogParser if you're on Windows.

It can run SQL-like queries against flat text files to perform all sorts of merge operations.

Frank Krueger
A: 

The previous answers using logparser or the commandline tools should work. If you want to do some more complicated operations to the records like filtering or joins, you could consider using an ETL Tool (Pentaho, Mapforce and Talend come to mind). These tools generally give you a graphical palette to define the relationships between data sources and any operations you want to perform on the rows.

Dana the Sane