awk -F '","' 'BEGIN {OFS=","} { if (toupper($5) == "STRING 1") print }' file1.csv > file2.csv
Výstup
"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",""
Myslím, že tohle je to, co chceš.
Problém CSV je v tom, že neexistuje žádný standard. Pokud potřebujete často pracovat s daty ve formátu CSV, možná budete chtít hledat robustnější metodu, než jen používat ","
jako oddělovač polí. V tomto případě Perl's Text::CSV
Moduly CPAN jsou pro tuto práci mimořádně vhodné:
$ 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",""