Sample Header Ad - 728x90

Combine .csv-files with different amount of lines

0 votes
3 answers
124 views
[Here I asked already for a similar problem.](https://unix.stackexchange.com/questions/735118/combine-csv-files-with-text-between-each-line "Combine .csv-files with text between each line") Now I have 3 .csv-files but one of them has only 1 line. **file1.csv**
dog
cats
mouse
**file2.csv**
001a
002a
003c
**file3.csv**
WORD
The output should be
dog,001a,WORD
cats,002a,WORD
mouse,003c,WORD
One solution ([from my previous question](https://unix.stackexchange.com/questions/735118/combine-csv-files-with-text-between-each-line "Combine .csv-files with text between each line")) is: paste -d, file1.csv file2.csv | awk -F, '{print $1 "," $2 ",WORD"}' But "WORD" is here just written and not read from file3.csv. Is there a way to tell paste to fill every line with file3.csv? Or maybe to save file3.csv as a variable and give it to awk?
Asked by R 9000 (167 rep)
Feb 12, 2023, 07:33 PM
Last activity: Feb 25, 2023, 06:20 PM