Încerc să găsesc o valoare specifică pentru fișierul meu, iată un fragment rapid al acestuia:
PRODUCT_TYPE_NAME,PRODUCT_CLASS_NAME,PRODUCT_SUB_CLASS_NAME,PRODUCT_MINOR_CLASS_NAME,PRODUCT_COUNTRY_ORIGIN_NAME,PRODUCT_SKU_NO,PRODUCT_LONG_NAME,PRODUCT_BASE_UPC_NO,PRODUCT_LITRES_PER_CONTAINER,PRD_CONTAINER_PER_SELL_UNIT,_PERD_CONTAINER_PER_SELL_UNIT,_PRODUCT_PERDIALCURRHOL,_PERDIALCURRHOL,_PRODUCT_PER_CENTRE_CURRHOL,_PER_CENTRE_PRODUIT
LICHIOR, VIN, VIN DE MESA, VIN DE MESA ROSU, CANADA, 198267, COPPER MOON - MALBEC, 48162013513,3,1,14,30.99,0
LICHIOR,VIN,VIN DE MESA,VIN DE MESA ALB,CANADA,305375,DOMAINE D'OR - DRY,48162001886,4,1,11.5,32.99,0
LICHIOR, VIN, VIN DE MESA, VIN DE MESA ROSU, CANADA, 53017, SOMMET ROUGE, 58976055050,4,1,12,29.99,0
LICHIOR,VIN,VIN DE MESA,VIN DE MESA ALB,CANADA,215525,MISSION RIDGE - PREMIUM DRY WHITE,779646155251,4,1,11,33.99,1
LICHIOR,VIN,VIN DE MESA,VIN DE MESA ROSIU,STATELE UNITE ALE AMERICII,168971,ZINFANDEL - BIG HOUSE CARDINAL ZIN,81308001456,3,1,13.5,36.99,0
LICHIOR, VIN, VIN DE MESA, VIN DE MESA ROSU, FRANTA,234559,LE VILLAGEOIS RED - CELLIERS LA SALLE,63657001448,4,1,11,34.99,0
LICHIOR, VIN, VIN DE MESA, VIN DE MESA ROSU, CANADA, 492314, SAWMILL CREEK - MERLOT, 63657004074,16,1,12.5,119,0
LICHIOR, VIN, VIN DE MESA, VIN DE MESA ALB, CANADA, 587584, SOLA, 63657006566,4,1,12,32.99,0
LICHIOR,VIN,VIN DE MESA,VIN DE MESA ALB,CANADA,100925,GANTON & LARSEN PROSPECT - PINOT BLANC BIRCH CANOE 2011,776545400000,0.75,1,11.5,13.99,0
LICHIOR,SPIRITURI,IRISH WHISKY,IRISH WHISKY,IRLANDA,10157,JAMESON - IRISH,80432500170,0,75,1,40,34,99,NA
LICHIOR,VIN,VIN DE MESA,VIN DE MESA ALB,ITALIA,102764,PINOT GRIGIO DELLE VENEZIE - RUFFINO LUMINA,8001660197156,0.75,1,12.5,15.99,0
LICHIOR,SPIRITURI,AMERICAN WHISKY,AMERICAN WHISKY,Statele Unite ale Americii,103747,MAKER'S MARK - KENTUCKY BOURBON,85246139431,0.75,1,45,44.95,NA
LICHIOR, SPIRITURI, GIN, DRY GIN, CANADA, 1040, GORDONS - LONDON DRY, 622153139040,0,75,1,40,24,49,NA
LICHIOR,VIN,VIN DE MESA,VIN DE MESA ALB,CANADA,104679,CALONA - RESERVA ARTIST SERIA PINOT GRIS 2011/13,58976501656,0.75,1,13.5,12.99,0
LICHIOR,VIN,VIN DE MESA,VIN DE MESA ROSIU,STATELE UNITE ALE AMERICII,106476,PINOT NOIR - SIDURI RUSUL RUS 11/12,626990184140,0.75,1,14.5,49.99,0
LICHIOR, SPIRITURI, CACHACA, CACHACA, BRAZILIA, 107029, CACHACA 61,7896547500676,0.7,1,40,28.95,2
LICHIOR,VIN,VIN DE MESA,VIN DE MESA ROSIU,FRANTA,109082,CHATEAU PAVIE DECESSE 2008,,0,75,1,13,239,0
LICHIOR, SPIRITURI, SCOTCH WHISKY, SCOTCH - BLEND, REGATUL UNIT, 1099, JOHNNIE WALKER - RED LABEL, 622153631049,0,75,1,40,29,99,NA
LICHIOR,VIN,VIN DE MESA,VIN DE MESA ROSIU,ITALIA,110460,LE CONTRADE - CO.PRO.VI,8004753004010,1,1,12,9.9,0
LICHIOR, SPIRITURI, ROM, DARK, CANADA, 112433, BACARDI - NEGRU, 620213055408,0,75,1,40,23,75,NA
LICHIOR,VIN,DESERT APERITIF ȘI VIN FORTIFICAT,MONTILLA,SPANIA,112789,ALVEAR - MEDIUM DRY,766238303374,0.75,1,17,17.99,3
LICHIOR, SPIRITURI, SCOTCH WHISKY, SCOTCH - BLEND, REGATUL UNIT, 112896, JOHNNIE WALKER - RED LABEL, 622153631070,1.75,1,40,68.99,NA
Acum trebuie să folosesc grep, aș prefera dacă soluția nu implică sed, perl, awk sau bucle. Am incercat:
grep -E „^.*(,.*){9}[^0]+” BC_Liquor_Store_Product_Price_List.csv
Dar asta, evident, primește totul.
Trebuie să obțin toate rândurile care au un PRODUCT_LITRES_PER_CONTAINER >= 1, dar pur și simplu nu îmi dau seama cum. .* primește totul, dar înainte de , există cuvinte, așa că nu pot face doar:
grep -E „^(,.*){9}[^0]+” BC_Liquor_Store_Product_Price_List.csv
care se vor potrivi numai liniile care încep cu ,?