粘贴两个数据文件时,排除列 [英] Exclude a column when pasting two data files

查看:124
本文介绍了粘贴两个数据文件时,排除列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件dat1.txt,这是这样的:

  0 5.71159e-01
1 1.92632e-01
2 -4.73603e-01

和另一个文件dat2.txt,这是:

  0 5.19105e-01
1 2.29702e-01
2 -3.05675e-01

写这两个文件合并成一个我用

 粘贴dat1.txt dat2.txt> data.txt中

不过,我不希望在输出文件第二个文件的第1列。如何修改UNIX命令?


解决方案

 粘贴dat1.txt≤(切-d,-f2- dat2.txt)

使用剪切除去第1列,并使用进程替换使用其输出粘贴

输出:

  0 5.71159e-01 5.19105e-01
1 1.92632e-01 2.29702e-01
2 -4.73603e-01 -3.05675e-01

I have one file "dat1.txt" which is like:

0 5.71159e-01
1 1.92632e-01
2 -4.73603e-01

and another file "dat2.txt" which is:

0 5.19105e-01
1 2.29702e-01
2 -3.05675e-01

to write combine these two files into one I use

paste dat1.txt dat2.txt > data.txt

But I do not want the 1st column of the 2nd file in the output file. How do I modify the unix command?

解决方案

paste  dat1.txt <(cut -d" " -f2- dat2.txt)

Using cut to remove column 1, and using process substitution to use its output in paste

Output:

0 5.71159e-01   5.19105e-01
1 1.92632e-01   2.29702e-01
2 -4.73603e-01  -3.05675e-01

这篇关于粘贴两个数据文件时,排除列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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