Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I recently ran across a bit of code injected to all of the files on a web site and I need to use perl or sed to remove it across all the files.

I am having trouble coming up with the exact pattern due to escaping.

I need to match and replace (with nothing) the following text

/0242d5/ .. javascript here ... /0242d5/

share|improve this question
2  
restore from your backups. its both quicker, and cleaner. –  Sirex May 5 '13 at 22:40
    
Backup? I don't have any :’( –  smonff Aug 9 '13 at 6:40
    
You should change your website security rules. If it has been possible to inject some JavaScript into these files they will try to do it again. Do you really want to infinitely run these Sed or Perl scripts? It should be usefull –  smonff Aug 9 '13 at 6:44
add comment

1 Answer

This seemed to suffice when I tested it.

sed -i 's/\/0242d5\/ .. javascript here ... \/0242d5\///' *.extension

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.