May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

How to merge contents of 2 files using paste?

This is one of the best command that facilitates the system admin to perform his specific tasks. Below is the list with the examples showing the paste command.

[localhost@localhost ~]$ cat file1
apple
orange
mango
banana

[localhost@localhost ~]$ cat file2
coldplay
westlife
michael
sunibigyana
piyush

[localhost@localhost ~]$ paste -s file1
apple orange mango banana

[localhost@localhost ~]$ paste -d, -s file1
apple,orange,mango,banana

[localhost@localhost ~]$ paste – – < file1 apple orange mango banana [localhost@localhost ~]$ paste -d':' - - < file1 apple:orange mango:banana [localhost@localhost ~]$ paste - - - < file1 apple orange mango banana [localhost@localhost ~]$ paste -d ':,' - - - < file1 apple:orange,mango banana:, [localhost@localhost ~]$ cat file2 coldplay westlife michael sunibigyana piyush [localhost@localhost ~]$ paste file1 file2 apple coldplay orange westlife mango michael banana sunibigyana piyush [localhost@localhost ~]$ paste -d, file1 file2 apple,coldplay orange,westlife mango,michael banana,sunibigyana ,piyush [localhost@localhost ~]$ cat file2 | paste -d, file1 - apple,coldplay orange,westlife mango,michael banana,sunibigyana ,piyush [localhost@localhost ~]$ cat file1 | paste -d, - file2 apple,coldplay orange,westlife mango,michael banana,sunibigyana ,piyush [localhost@localhost ~]$ cat file1 file2 | paste -d, - - apple,orange mango,banana coldplay,westlife michael,sunibigyana piyush, [localhost@localhost ~]$ paste -d'\n' file1 file2 apple coldplay orange westlife mango michael banana sunibigyana piyush [localhost@localhost ~]$

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>