[英]How can i paste columns from separate files using bash?
I want to merge different lists with delimiter "-".我想用分隔符“-”合并不同的列表。
first list has 2 words第一个列表有 2 个词
$ cat first
one
who
second list has 10000 words第二个列表有 10000 个单词
$ cat second
languages
more
simple
advanced
home
expert
......
......
test
nope
i want two list merge, same ...我想要两个列表合并,相同...
$cat merge-list
one-languages
one-more
....
....
who-more
....
who-test
who-nope
....
Paste should do the trick.粘贴应该可以解决问题。
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 是一个 Unix 命令行实用程序,用于水平连接文件(并行合并),方法是将指定的每个文件的顺序对应行组成的行输出到标准输出,以制表符分隔。
Example例子
paste -d - file1 file2
EDIT:编辑:
I just saw that your two files have different length.我刚刚看到你的两个文件有不同的长度。 Unfortunately paste is not helping with these kinds of problems.
不幸的是,粘贴对解决此类问题没有帮助。 But you could of course use something like this:
但是你当然可以使用这样的东西:
for i in `cat file1`; do
for j in `cat file2`; do
echo $i-$j
done
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.