AWK过滤CSV文件

前端之家收集整理的这篇文章主要介绍了AWK过滤CSV文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想过滤掉第3列中“同义”的行.命令如下
awk '$3 !~ /^synonymous/' fileCSV.csv > fileCSV2.csv

但是fileCSV2.csv在第3列中仍然包含单词“synonymous”.我想知道可能出错了什么?

fileCSV.csv中的两行:

"exonic","LINC00115","synonymous SNV","uc010nxx.2:c.C299T:p.P100L","0.99",0.56,rs3115849,chr1,762273,G,A,"chr1","762273",".","G","A","30483.62","PASS","AC=24;AF=1.00;AN=24;DP=2972;FS=0.000;MLEAC=8;MLEAF=1.00;MQ0=0;VQSLOD=19.50;culprit=FS;set=Intersection","GT:AD:DP:GQ:PL","1/1:0,2:2:6:66,6,0",297:297:99:10476,951,304:304:99:10098,950,295:295:99:9869,929,292:292:99:8655,895,304:304:99:10006,965,179:179:99:5862,568,273:273:99:9328,851,279:279:99:7946,850,283:283:99:9214,866,8:8:21:229,21,456:456:99:16385,1285,0"    
"exonic","SAMD11","uc001abw.1:c.T1027C:p.W343R","559;Name=lod=249",1.00,rs6672356,1,0.916445,N,0.0,T,B,0.998605,4.19E-4,3.17,877831,C,"877831","T","C","3594.56","AC=24;AF=1.00;AN=24;DP=387;FS=0.000;MLEAC=8;MLEAF=1.00;MQ=60.00;MQ0=0;VQSLOD=15.00;culprit=DP;set=Intersection",3:3:9:97,9,3:3:12:113,12,64:64:99:1805,189,57:57:99:1605,168,30:30:90:768,90,69:69:99:2026,216,15:15:45:428,45,23:23:81:809,81,22:22:69:562,69,40:40:99:1142,117,3:3:9:94,58:58:99:14,7,0"

解决方法

如果您的fileCSV.csv具有由您需要的列分隔的列
awk -F,'$3 !~ /^synonymous/' fileCSV.csv > fileCSV2.csv

如果-F不适用于您的awk版本,请尝试

awk 'BEGIN{FS=","} $3 !~ /^synonymous/' fileCSV.csv > fileCSV2.csv

编辑:你还需要“考虑到,所以使用/ ^”同义/

原文链接:https://www.f2er.com/linux/395071.html

猜你在找的Linux相关文章