1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to delete lines if it contain certain character ?

Discussion in 'BlackHat Lounge' started by MethShow, Mar 27, 2011.

  1. MethShow

    MethShow Registered Member

    Joined:
    Jan 24, 2011
    Messages:
    57
    Likes Received:
    2
    How to delete lines if it contain certain character ?

    Let's say, I have a text file like this -

    aaa aaa
    bbb bbb
    ccc ccc e
    ddd ddd
    fff fff e

    Now, I want to remove all the lines that contain the word "e", so after I run the software, I will get -

    aaa aaa
    bbb bbb
    ddd ddd

    Do you guys know any software or method that can do this ?

    Thanks
     
  2. Zak_A

    Zak_A Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 16, 2008
    Messages:
    808
    Likes Received:
    873
    Gender:
    Male
    Occupation:
    WP designer & developer
    Location:
    Western Europe
    I'd say RegEx if you're a php coder.

    Or you can also do this easily in excel with a formula using FIND, ISNUMBER and IF.
     
  3. Jayemdae

    Jayemdae Newbie

    Joined:
    Feb 15, 2010
    Messages:
    46
    Likes Received:
    36
    Occupation:
    Techie
    Location:
    Indianapolis, IN
    Off the top of my head, I'd use a spreadsheet for this.

    Load up your text file into a spreadsheet, then create a formula in a column (right or left...it doesn't matter) that searches for the string and "flips a switch" if found (using and if statement). You can then sort the entire list by this field and delete all the rows in one fell swoop. Then it's just a matter of saving the file back out with just the rows you need.
     
  4. MethShow

    MethShow Registered Member

    Joined:
    Jan 24, 2011
    Messages:
    57
    Likes Received:
    2
    Wow man, you are the man.:)
     
  5. wkrappen91

    wkrappen91 Power Member

    Joined:
    Sep 9, 2010
    Messages:
    588
    Likes Received:
    720
    Location:
    127.0.0.1