awk一个班轮仅根据一列的值选择行 [英] awk one liner select only rows based on value of a column
本文介绍了awk一个班轮仅根据一列的值选择行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想阅读 filein.txt (制表符分隔),并输出一个 fileout.txt ,其中仅包含与给定列的值匹配的行,并消除正在查询的列.即
I'd like to read filein.txt (tab delimited) and output a fileout.txt with only rows that match the value of a given column, and eliminate the column being queried. i.e.,
filein.txt
#name\thouse\taddress
roger\tvictorian\t223 dolan st.
maggie\tfrench\t12 alameda ave.
kingston\tvictorian\t224 house st.
robert\tamerican\t22 dolan st.
让我们说,我只想选择房屋为victorian
风格的行,那么我的 fileout.txt 应该如下所示:
Let us say I'd like to select only the rows where the houses are of victorian
style, then my fileout.txt should look like:
fileout.txt
#name\taddress
roger\t223 dolan st.
kingston\t224 house st.
推荐答案
awk -F"\t" '$2 == "victorian" { print $1"\t"$3 }' file.in
这篇关于awk一个班轮仅根据一列的值选择行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文