Murali Marimekala
Murali Marimekala

Reputation: 73

Append a new column at end of csv file using shell script

I am parsing few logs where I extract a single column from each log. I need to keep on appending them to a csv file.

Please let me know how to achieve this. Thanks in advance.

Upvotes: 1

Views: 810

Answers (1)

therealneil
therealneil

Reputation: 5300

Given

$ cat foo.txt 
foo0
foo1
foo2
$ cat bar.txt 
bar0
bar1
bar2
$ cat qux.txt 
qux0
qux1
qux2

You can use paste and -delimit with ,:

$ paste -d, foo.txt bar.txt qux.txt
foo0,bar0,qux0
foo1,bar1,qux1
foo2,bar2,qux2
$

Upvotes: 2

Related Questions