这是 3 个文件:
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
我想将它们结合在一起并得到一个最终文件,例如:
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
但是当我使用时:
paste file1 file2 file3 > file4
我看到输出中存在差距(文件4):
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
我应该怎么做才能看不到这些差距?
答案1
我试过
paste -d ' ' file1 file2 file3 > file4
效果很好。在 MacOS 上测试。
答案2
尝试paste -d ' ' file1 file2 file3
。从手册:
-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.