删除其中,第1列有具体的数字条目的所有行 [英] Delete all lines where column 1 has specific numeric entries
本文介绍了删除其中,第1列有具体的数字条目的所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新来的Unix和我有一个大的csv文件,我想删除所有的线,其中第1列具有值大于1。
I'm new to Unix and I have a large csv file where I want to delete all the lines where Column 1 has values greater than 1.
鸭preciate你的帮助。
Appreciate your help.
推荐答案
如果您要删除线,其中山坳1→1
,这意味着你要保留那些第1栏< = 1
。因此,这个 AWK
将使其:
If you want to delete lines where col 1 >1
, it means that you want to keep those whose col 1 <=1
. Hence, this awk
will make it:
awk '$1<=1' file > new_file
如果你想圆设置它的其他方式,否定了条件:
If you want to set it the other way round, negate the condition:
awk '!($1>1)' file > new_file
根据Jaypal的好建议,你可能在你需要指明域分隔符的情况。如果是这样,用 -F
参数做到这一点:
awk -F"," '$1<=1' file > new_file # field separator is ,
awk -F";" '$1<=1' file > new_file # field separator is ;
这篇关于删除其中,第1列有具体的数字条目的所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文