1

i am trying to search my server and find the following in any files.

my regex grep -H -r '/\<\?php\spreg_replace\(\"\/\.\*\/e\"\,\.*?\)\;\?\>/gi' /var/www/html/optinsmart/

i'm looking for this <?php preg_replace("/.*/e"anything in here);?> and i want to replace it with nothing or just simply remove it.

it isn't returning any matches at the command line

but when i do grep '<?php preg_replace("/.*/e"' /var/www/optinsmart/ it returns all of them

is there something wrong in my regex?

EDIT

i am trying to find <?php preg_replace("/.*/e"???);?> where ??? could be anything.

1
  • 2
    I'm looking for this. Please be specific what you want to achieve instead of just referring to your regex. Commented Feb 26, 2014 at 23:07

1 Answer 1

1

You can use grep -F (fixed string without regex):

grep -FHr '<?php preg_replace("/.*/e"' *

To delete these line use this sed:

sed -i.bak '/<?php preg_replace("\/.*\/e"/d' *
Sign up to request clarification or add additional context in comments.

5 Comments

but i need to get the whole PHP code. <?php preg_replace("/.*/e"???);?> and the ??? could be anything.. gh32947gh9h 0r a word or numbers or dashes...
But even that line is also starting with same text '<?php preg_replace("/.*/e"' so should it not be fine?
so with will only go to the end of the line?
my server got hacked and that code snippet was added to the bottom of all my index.php files. so i want to search for it and remove it from all the files.. Will what you suggested for for that?
i ended up using find ./ -name "index.php" | xargs sed -i '/<?php preg_replace("\/.*\/e"/d'. Thnak you for your help and pointing me in the right direction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.