1

These are 3 files:

file1   file2   file3
1 2 3   1 1 1   3 3 3
2 1 3   1 1 1   3 3 3
0 0 0   1 1 1   3 3 3

I want to join them together and have a final file like:

1 2 3 1 1 1 3 3 3
2 1 3 1 1 1 3 3 3
0 0 0 1 1 1 3 3 3

But when I use :

paste file1 file2 file3 > file4

I see gap in output(file4):

1 2 3   1 1 1   3 3 3
2 1 3   1 1 1   3 3 3
0 0 0   1 1 1   3 3 3

What should I do to not see these gaps?

don_crissti
  • 82,805
zara
  • 1,313
  • Your title is misleading. You want to use a space as a delimiter... I'm retracting my close vote but next time try to find a more suitable title... – don_crissti Aug 23 '17 at 23:09

2 Answers2

3

Try paste -d ' ' file1 file2 file3. From the manual:

 -d list     Use one or more of the provided characters to replace the newline characters
             instead of the default tab.  The characters in list are used circularly, i.e., when
             list is exhausted the first character from list is reused.  This continues until a
             line from the last input file (in default operation) or the last line in each file
             (using the -s option) is displayed, at which time paste begins selecting characters
             from the beginning of list again.
         The following special characters can also be used in list:

         \n    newline character
         \t    tab character
         \\    backslash character
         \0    Empty string (not a null character).

         Any other character preceded by a backslash is equivalent to the character itself.

DopeGhoti
  • 76,081
3

I tried

paste -d ' ' file1 file2 file3 > file4

and it worked fine. Tested on MacOS.

unxnut
  • 6,008