Merge lines of files

Paste command merges lines of files. In one way, it joins two files. Note that
join command has different meaning. I will talk about join command some other day.

Let us take one example of paste.

rahul@rahul-Aspire-4736Z:~$ cat test1.txt 
1
2
3
4
5
6
rahul@rahul-Aspire-4736Z:~$ cat test2.txt 
a
b
c
d
e
f

rahul@rahul-Aspire-4736Z:~$ paste test1.txt test2.txt -d " "
1 a
2 b
3 c
4 d
5 e
6 f

Paste merges lines of files in parallel and with tab as delimiter by default. If you want to merge lines one by one that is in serial, then specify -s option.

Delimiter can be specified by -d option.

rahul@rahul-Aspire-4736Z:~$ paste test1.txt test2.txt -s
1    2    3    4    5    6
a    b    c    d    e    f

Enjoy!

Post a Comment

You must be logged in to post a comment.
%d bloggers like this: