awk -F '","' 'BEGIN {OFS=","} { if (toupper($5) == "STRING 1") print }' file1.csv > file2.csv
Sortie
"12310","42324564756","a simple string with a , comma","string with or, without commas","string 1","USD","12","70%","08/01/2013",""
"23525","74535243123","string , with commas, and - hypens and: semicolans","string with or, without commas","string 1","CAND","744","70%","05/06/2013",""
Je pense que c'est ce que vous voulez.
Le problème avec CSV est qu'il n'y a pas de norme. Si vous devez souvent traiter des données au format CSV, vous pouvez envisager une méthode plus robuste plutôt que d'utiliser simplement ","
comme séparateur de champs. Dans ce cas, le Text::CSV
de Perl Les modules CPAN sont exceptionnellement bien adaptés au travail :
$ perl -mText::CSV_XS -WlanE '
BEGIN {our $csv = Text::CSV_XS->new;}
$csv->parse($_);
my @fields = $csv->fields();
print if $fields[4] =~ /string 1/i;
' file1.csv
"12310","42324564756","a simple string with a , comma","string with or, without commas","string 1","USD","12","70%","08/01/2013",""
"23525","74535243123","string , with commas, and - hypens and: semicolans","string with or, without commas","string 1","CAND","744","70%","05/06/2013",""