awk -F '","' 'BEGIN {OFS=","} { if (toupper($5) == "STRING 1") print }' file1.csv > file2.csv
Keluaran
"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",""
Saya pikir Inilah yang Anda inginkan.
Masalah dengan CSV adalah tidak ada standar. Jika Anda harus sering berurusan dengan data berformat CSV, Anda mungkin ingin mencari metode yang lebih kuat daripada hanya menggunakan ","
sebagai pemisah bidang Anda. Dalam hal ini, Text::CSV
Perl Modul CPAN sangat cocok untuk pekerjaan:
$ 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",""