开发者

display two files horizontally in the shell

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜