November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

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>