How to paste columns from separate files using bash?

You were on track with paste(1):

$ paste -d , date1.csv date2.csv 
Bob,2013-06-03T17:18:07,2012-12-02T18:30:31
James,2013-06-03T17:18:07,2012-12-02T18:28:37
Kevin,2013-06-03T17:18:07,2013-06-01T12:16:05

It’s a bit unclear from your question if there are leading spaces on those lines. If you want to get rid of that in the final output, you can use cut(1) to snip it off before pasting:

 $ cut -c 2- date2.csv | paste -d , date1.csv -
  Bob,2013-06-03T17:18:07,2012-12-02T18:30:31
  James,2013-06-03T17:18:07,2012-12-02T18:28:37
  Kevin,2013-06-03T17:18:07,2013-06-01T12:16:05

Leave a Comment