Couldn't help to golf that. :) awk -v FS=, '$7 !~ /Gen12[cu]/'
Regards, - Robert On Wed, Sep 23, 2020 at 1:02 PM <tomas.kuchta.li...@gmail.com> wrote: > cat inputFile | awk -v FS=, '$7~/Gen12c|Gen12u/ {next; } {print;}' > > outFile > > On Wed, 2020-09-23 at 12:44 -0700, Rich Shepard wrote: > > Using gawk I want to print all lines in a file except those that have > > any of > > three patterns in field 7. I thought I had the proper syntax but gawk > > disagrees and I'm not finding the proper syntax in my awk books or in > > web > > searches. I've tried using if-else (my first choice), as well as > > negating > > the patterns but everything's failed. > > > > Here's the script, drop-1200C.awk: > > 8< ----- > > BEGIN { FS=OFS="," } > > { if (/$7 ~ "Gen12c"/ || /$7 ~ "Gen12c(Agent)"/ || /$7 ~ "Gen12u"/) > > { next } > > else > > { print $0 > "processed.dat" } > > } > > -------- >8 > > > > And here's a sample input file, sample.dat: > > 8<--------------- > > '123095','2842','20/10 Products Inc.','20/10 > > Products','Salem','Marion','Gen12z' > > '111677','5015','205 Auto Salvage Inc.','205 Auto Salvage > > Inc.','Portland','Multnomah','Gen12z' > > '108572','1442','4-R Equipment LLC','4-R Equipment > > LLC','Philomath','Benton','Gen12a' > > '111223','2493','48th St LLC','48th St > > LLC','Springfield','Lane','Gen12z' > > '102952','1442','Abadaba Inc','Riverbend Materials-Esg South > > Pit','Eugene','Lane','Gen12a' > > '70200','1541','Age, Frank','New Plant > > Site','Brownsville','Linn','Gen12c' > > '105395','2813','Airgas USA LLC','Airgas USA > > LLC','Mcminnville','Yamhill','Gen12z' > > '126624','4925','Airgas USA > > LLC','Airgas','Portland','Multnomah','Gen12z' > > '125593','1521','Akins',' Clyde','Lilybrook > > Subdivision','Medford','Jackson','Gen12c' > > '100520','2851','Akzo Coatings Inc','Akzo Coatings > > Inc','Salem','Marion','Gen12z' > > '124676','1522','Amberglen Development LLC','Amberglen On The > > Park','Hillsboro','Washington','Gen12c(Agent)' > > '125887','1522','Amberglen South Development Company LLC','Amberglen > > South Apartments','Hillsboro','Washington','Gen12c(Agent)' > > '126441','1623','Antelope, City Of ','Water Transmission',' Storage & > > Distribution Improvements Project','Antelope','Wasco','Gen12c' > > '119429','9511','Lake Oswego, City Of','City Of Lake Oswego','Lake > > Oswego','Clackamas','Gen12u' > > '125935','1611','Lake Oswego, City Of','Boones Ferry Road Project- > > Phase 1','Lake Oswego','Clackamas','Gen12c' > > '118763','3599','Apex Machinery Inc.','Apex > > Machinery','Eugene','Lane','Gen12z' > > ---------->8 > > > > When I run all versions of awk scripts either all lines are output or > > I get > > doubled lines. > > > > What have I missed in writing the gawk script? > > > > Rich > > _______________________________________________ > > PLUG: https://pdxlinux.org > > PLUG mailing list > > PLUG@pdxlinux.org > > http://lists.pdxlinux.org/mailman/listinfo/plug > _______________________________________________ > PLUG: https://pdxlinux.org > PLUG mailing list > PLUG@pdxlinux.org > http://lists.pdxlinux.org/mailman/listinfo/plug > _______________________________________________ PLUG: https://pdxlinux.org PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug