notam2774
notam2774

Reputation: 171

sed text replace

How can I replace text with other text using GNU sed? I was hacked and am just trying to see if I can remove some of the code that was placed into my php files. The text is of the

eval(base64_decode('blah'));

variety. All of them are identical, I would just like to find and replace all of them in all files. I have tried some commands, but they either needlessly alter and damage text in the files or simply fail to launch at all.

Upvotes: 0

Views: 2283

Answers (2)

Justin Thomas
Justin Thomas

Reputation: 5848

find . -name \*.php -exec sed -i "s/text/other/g" {} \;

You may want to do a dry run and leave off the -i and just direct it to a file as a test first.

On Mac the -i usually doesn't work.

Upvotes: 1

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143229

sed -i 's/text/other text/g' filename

(sed -i "s/eval(base64_decode('blah'))/huh/g" filename in your case).

Upvotes: 2

Related Questions