Display two files horizontally in a shell

file 1:

dsf sdfsd dsfsdf 

file 2:

 sdfsdfsd sdfsdsdfsdf dsfsdfsdfsdf 

I want to cat two files horizontally, so the result:

 dsf sdfsdfsd sdfsd sdfsdsdfsdf dsfsdf dsfsdfsdfsdf 

thanks

+4
source share
1 answer

You can use the paste command as:

 paste file1 file2 

Demo:

 $ cat file1 1 2 3 $ cat file2 3 4 5 $ paste file1 file2 1 3 2 4 3 5 $ 

The default character used as the delimiter is the tab. If you want some other character to say a space, you can use the -d option as:

 paste -d ' ' file1 file2 
+5
source

All Articles