Reputation: 21
I have two txt files, first one contains:
000
111
222
333
444
and the second one contains:
.
How can I merge this two text files in the unix terminal, so I can get another file that contains:
.000
.111
.222
.333
.444
Thanks for your answers
Upvotes: 1
Views: 59
Reputation: 10582
The paste
command is generally what you're looking for, but it expects both files to have the same number of lines. You can create a file with the same number of lines repeated with something like yes $(cat file2) | head -$(wc -l < file1)
So the whole thing, using bash file substitution:
paste -d "" <(yes $(cat file2) | head -$(wc -l <file1)) file1
Upvotes: 1