bash sed/awk - 如何删除少于 3 列的行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15643440/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 04:59:40  来源:igfitidea点击:

sed/awk - How to remove lines with less than 3 columns

bashsedawk

提问by Numpty

Really simple question. I simply need to remove lines from a list when there are less than 3 columns

真的很简单的问题。当少于 3 列时,我只需要从列表中删除行

Eg:

例如:

a b c
a b      <--- This one needs to disappear
a b c

I'm pretty sure awk NF does it, however I can't seem to get it right.

我很确定 awk NF 会这样做,但是我似乎无法正确完成。

Thanks in advance!

提前致谢!

回答by Kent

sed, grep, awk all can do this job. since you prefer awk, see if this helps?

sed、grep、awk 都可以完成这项工作。因为你更喜欢 awk,看看这是否有帮助?

awk 'NF>=3' file