我想用分隔符“-”合并不同的列表。
第一个列表有 2 个词
$ cat first
one
who
第二个列表有 10000 个单词
$ cat second
languages
more
simple
advanced
home
expert
......
......
test
nope
我想要两个列表合并,相同...
$cat merge-list
one-languages
one-more
....
....
who-more
....
who-test
who-nope
....
最佳答案
<德尔> Paste应该做的伎俩。
paste is a Unix command line utility which is used to join files horizontally (parallel merging) by outputting lines consisting of the sequentially corresponding lines of each file specified, separated by tabs, to the standard output.
例子
paste -d - file1 file2
编辑:
我刚刚看到您的两个文件的长度不同。不幸的是粘贴不是 帮助解决这类问题。但是你当然可以使用这样的东西:
for i in `cat file1`; do
for j in `cat file2`; do
echo $i-$j
done
done
关于linux - 如何使用 bash 粘贴来自不同文件的列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44789346/