如何从一个文件中添加一列到另一个文件 [英] How to add a column from a file to another file

查看:101
本文介绍了如何从一个文件中添加一列到另一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两列的文件

  1
2 3
3 4

和一个列

文件

  6
7
9

我想添加第二个文件中的第一个。输出应该是:

  1 1 6
2 3 7
3 4 9


解决方案

  $ PR -mts'文件1文件2
1 1 6
2 3 7
3 4 9$粘贴-d'文件1文件2
1 1 6
2 3 7
3 4 9

I have a file with two columns as

1 1
2 3
3 4

and a file with one column as

6
7
9

I would like to add the second file in the first one. The output should be:

1 1 6
2 3 7
3 4 9

解决方案

$ pr -mts' ' file1 file2
1 1 6
2 3 7
3 4 9

$ paste -d' ' file1 file2
1 1 6
2 3 7
3 4 9

这篇关于如何从一个文件中添加一列到另一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆