telnet find perl question

Discussion in 'Programming' started by glasglow, May 17, 2010.

  1. #1
    I have two questions here please. The first is concerning this:

    find //directory "*.php"|xargs perl -w -i -p -e "s/FIND/REPLACE/g"

    This works just fine, but I've ran into some problems. I need to find exactly this piece of code and I am unable to process it because of things inside the code. Is there a way to search for this here:

    <?php /**/ eval(base64_decode("+=="));?>

    For example, because of the + plus sign. It stops the code and I'm not sure how to get it into the search.

    The second question is, I'm using this for a find-replace but for the life of me I don't know how to get the file name of something found. For example, just a search function, not a search replace function.

    Thanks! P.S. Any answer needs to be a one-liner please for use in telnet.
     
    glasglow, May 17, 2010 IP
  2. Fervid

    Fervid Well-Known Member

    Messages:
    161
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    120
    #2
    You'd have to escape special characters with a \.
     
    Fervid, May 18, 2010 IP
  3. glasglow

    glasglow Active Member

    Messages:
    926
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    No kidding as simple as that... silly me. Similar to php. Thank you very much.

    Ok, how about the second question please.

    "The second question is, I'm using this for a find-replace but for the life of me I don't know how to get the file name of something found. For example, just a search function, not a search replace function."
     
    Last edited: May 18, 2010
    glasglow, May 18, 2010 IP
  4. Fervid

    Fervid Well-Known Member

    Messages:
    161
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    120
    #4
    You can do grep -l "whatever" *.html (or whatever will match the files you want to search)
     
    Fervid, May 19, 2010 IP