Delete whole line based on pattern

Discussion in 'Programming/Scripts' started by ramangill, Nov 1, 2007.

  1. ramangill

    ramangill New Member

    Hi,

    We have a file with about 10,000 lines. I would like to remove a whole line based on a pattern. For example...

    ADD TABLE "accountingprefyr_subsc"
    AREA "systemdata"
    LABEL "Accounting Preference Year"
    DUMP-NAME "acctyear"


    The 2nd line here starts with AREA "

    We have noticed that this is always on its own line. So basically the pattern should be AREA "*. * Being the wild card for whatever comes after. So when parsing through the file, whenever it finds this patterns, I would like to delete the line completly. Can someone please help me on this.
     
  2. ghostdog74

    ghostdog74 New Member

    with awk

    Code:
    awk '!/AREA/{print}' "file" > newfile
    mv newfile file
    
    with sed
    Code:
    sed -i '/AREA/d' file
    
     

Share This Page