awk:根据另一列的值打印列 [英] awk: print columns based on values of another column

查看:106
本文介绍了awk:根据另一列的值打印列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含六列的文件,我只想在第六列中打印值> 3的行的前两列.

I have a file with six columns, and I only want to print the first two columns of the lines that have a value >3 in the sixth column.

此语句将打印第六行> 3

This statement prints all lines where the sixth column > 3

awk '$6 > 3' file > out

此语句显示前两列:

awk '{print $1,$2}' file > out 

任何人都知道如何将这两个命令组合成一个单行吗?

Anyone knows how to combine these two commands into a one-liner?

推荐答案

您就快到了,就像您所说的,将它们合并"! .试试这个:

you are almost there,just as you said, "combine them"! . try this:

awk '$6>3{print $1,$2}' file >out

这篇关于awk:根据另一列的值打印列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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