开发者

display two files horizontally in the shell

开发者 https://www.devze.com 2023-01-29 12:05 出处:网络
file 1: dsf sdfsd dsfsdf file 2: sdfsdfsd sdfsdsdfsdf dsfsdfsdfsdf I want to cat two files horizontally so the result is:

file 1:

dsf
sdfsd
dsfsdf

file 2:

sdfsdfsd
sdfsdsdfsdf
dsfsdfsdfsdf

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

dsf        sdfsdfsd
sdfsd      sdfsdsdfsdf
dsfsdf     dsfsdfsdfsdf
开发者_如何学JAVA

thanks


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 delimiter is tab. If you want some other character say space, you can use the -d option as:

paste -d ' ' file1 file2
0

精彩评论

暂无评论...
验证码 换一张
取 消