Paste
如何使用單個空格作為分隔符將多個文件粘貼在一起
這是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
我在輸出(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
我應該怎麼做才能看不到這些差距?
我試過
paste -d ' ' file1 file2 file3 > file4
它工作得很好。在 MacOS 上測試。
試試
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.