合并Linux中具有不同列的两个文件 [英] Merge two files in linux with different column

查看:126
本文介绍了合并Linux中具有不同列的两个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在linux中有两个文件,第一个文件有4列,第二个文件有2列.我想将这些文件合并为一个新文件,该文件具有文件1的前3列和文件2的第一列.我尝试了awk,但文件2的数据位于文件1下.

I have two files in linux, the first file has 4 columns and the second has 2 columns. I want to merge these files into a new file that has the first 3 columns from file 1 and the first column from file 2. I tried awk, but my data from file 2 was placed under file 1.

推荐答案

paste file1 file2 | awk '{print $1,$2,$3,$5}'

这篇关于合并Linux中具有不同列的两个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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