سؤال

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

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top