1

I have two (or maybe more) files:

file1.csv

dog
cats
mouse

file2.csv

001a
002a
003c

If I use paste file1.csv file2.csv the output is

dog 001a
cats    002a
mouse   003c

Of course I can use paste -d , file1.csv file2.csv

dog,001a
cats,002a
mouse,003c

But I want this output

TEXT1-dog-TEXT2-001a-TEXT3
TEXT1-cats-TEXT2-002a-TEXT3
TEXT1-mouse-TEXT2-003c-TEXT3

Is there a way to put multiple .csv files together with extra text before, between and after each line?

0

1 Answer 1

1

A KISS solution based on what you have so far:

paste -d, file1.csv file2.csv | awk -F, '{print "TEXT1-" $1 "-TEXT2-" $2 "-TEXT3"}'

or

paste -d, file1.csv file2.csv | awk -F, '{print "TEXT1", $1, "TEXT2", $2, "TEXT3"}' OFS=-

(which may be more convenient if you want to make the TEXTs variable).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .