2

Essentially, I have a csv file that contain multiple columns, called cols.csv

1,a,100
2,b,200
3,c,300
4,e,400

and I have a new csv file that has one column, called col.csv

f
g
h
i

I want to copy the items in col.csv and append them to the end of each line in cols.csv so that, cols.csv now contains those

1,a,100,f
2,b,200,g
3,c,300,h
4,e,400,i

is that possible at all? i tried join, paste, nothing worked

4

Contents of test1.txt

1,a,100
2,b,200
3,c,300
4,e,400

Contents of test2.txt

f
g
h
i

Sample.

$ paste -d, test1.txt test2.txt 
1,a,100,f
2,b,200,g
3,c,300,h
4,e,400,i

Explanation

We're using the -d flag to set the delimiter to a ,

2

Use the -d flag to paste to set the delimeter to a comma:

paste -d, cols.csv col.csv

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.