Skip to content
Advertisement

How do I copy lines next to line of another file in Linux?

let’s say I have two files:

file1:

cat dog
fox bat
rat pig

file2:

frog
deer
mouse

How can I get file3?

cat dog frog
fox bat deer
rat pig mouse

Advertisement

Answer

Linux has paste command. Basic example is as follows.

paste file1 file2 > file3

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement