[英]Delete lines in CSV file with a column condition in bash
I have a big CSV file (5Go). 我有一个很大的CSV文件(5Go)。 The header is: 标头是:
run number,export,downerQ,coefUpQuality,chooseMode,demandF,nbPLots,standarDevPop,nbCitys,whatWord,priceMaxWineF,marketColor,[step],giniIndexReserve,giniIndexPatch,meanQualityTotal,meanQualityMountain,meanQualityPlain,DiffExtCentral,nbcentralPlots,meanPatchByNetwork,sum_q_viti_moutain,sum_q_viti_plaine
"3","false","0.5","0.01","false","7000","10","2","10","0","70","false","0","0","0.07083333333333335","0","0","0","0","0","0","48","0"
"4","false","0.5","0.01","false","7000","10","2","10","0","70","false","0","0","0.04285714285714286","0","0","0","0","0","0","42","0"
"2","false","0.5","0.01","false","7000","10","2","10","0","70","false","0","0","0.05348837209302328","0","0","0","0","0","0","43","0"
I would like keep only rows that contain "500" in the field [step] (the thirteenth field). 我只想在字段[step](第13个字段)中保留包含“ 500”的行。
Does someone have a solution with tools like sed
, awk
or any other command? 有人使用sed
, awk
或其他任何命令提供解决方案吗?
awk seems the way to go: awk似乎要走的路:
awk -F, 'NR == 1 || $13 == "\"500\""' filename
Where NR == 1
is to preserve the first line (the header), and after that it's only lines of which the 13th field is "500"
. NR == 1
是为了保留第一行(标题),此后仅保留第13个字段为"500"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.