在 Linux 操作系统中,我在将两个其他文件中的字符串合并为一个时遇到问题。
例如: 我有 file1.txt 和 file2.txt file1.txt 包含字符串
word1
word2
word3
word4
文件2包含字符串
a
b
c
d
如何使用 contains 创建新文件?
word1 a
word2 b
word3 c
word4 d
最佳答案
让你的file1.txt
包含
word1
word2
word3
word4
和file2.txt
包含
a
b
c
d
然后要创建一个在两列之间有空格的新文件 file3.txt
,请在终端中使用以下命令。
paste -d' ' file1.txt file2.txt > file3.txt
这里的-d
关键字用于在两列之间放置分隔符(这里是空格)。
您将在 file3.txt
word1 a
word2 b
word3 c
word4 d
希望它是清楚的。
关于linux - 如何将2个文件中的字符串合并为1个并用空格分隔?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52227573/