sed help

Discussion in 'Site & Server Administration' started by flOid, Mar 4, 2007.

  1. #1
    So for a forum spam filter I need to extract the spam bot IP addresses from http://www.clanorb.com/banlist.php, and converts it into a single file with an IP address for each line.

    I got stuck at this sed command:
    sed -n -e '/159.148.11.5,/,/div/p' banlist.php > banlist
    Code (markup):
    But there is still html code at the end of the line that needs to be removed, but I didn't succeed in finding the sed command for that. Also the sed command I tryed for replacing the commas with line breaks isn't working:

    sed 's/,/\n/g' csv.file  > linefeed.file
    Code (markup):
    Any help?
     
    flOid, Mar 4, 2007 IP
  2. tanfwc

    tanfwc Peon

    Messages:
    579
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Maybe you like to use '$' as it will tell sed that it is the end of what you are trying to find.
     
    tanfwc, Mar 9, 2007 IP
  3. ThreeGuineaWatch

    ThreeGuineaWatch Well-Known Member

    Messages:
    1,489
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    140
    #3
    Not entirely sure what you are trying to do, but you can MacGyver it with something like this...

    wget http://www.clanorb.com/banlist.php && grep ^"<tr>" banlist.php | grep 7pt | cut -f4 -d '>' | tr -d "</span" > IPs
    Code (markup):
     
    ThreeGuineaWatch, Mar 12, 2007 IP