我有这个 CSV 文件:
"mikecook1966","6days","","Classy1","7/2020"
"kyndrion","1min","","Doominator handle","7/2020"
"Ataca","Feb2,2020","","Soporte 30.5x30.5 VTX-DVR Speedy Bee","7/2020"
我想保留输出结果,其中第 2 列包含2020
.
输出示例:
"Ataca","Feb2,2020","","Soporte 30.5x30.5 VTX-DVR Speedy Bee","7/2020"
答案1
如果您的 CSV 不包含转义双引号,您可以使用 grep:
grep '^"[^"]*","[^"]*2020' file.csv
对于更复杂的 CSV,需要一个支持 CSV 的工具。
perl -MText::CSV_XS=csv -e 'csv( in => "file.csv",
filter => { 2 => sub{ /2020/ } } )'