1

I have a list of files where I need to remove some lines that have been added yesterday by a spambot. The section I want to remove looks like this:

^M <script>[...] bunch of malware code [...]</script> 

That section seems to have been appended to the files, so I can be relatively sure it's the last lines of each file that contain this part.

Now I know a bit of Linux, but not enough to do this via a command. How would I go about and do this?

1 Answer 1

4

Is the malware code consistent? does it start and end with the same text in all cases??

If you can write a regexp, you can do something like:

perl -npi.bak -e 's/startofcode.*?endofcode//' file1 file2 file3 orglob* 
1
  • 1
    or sed if perl is not available on the machine (unusual but could happen) Commented May 14, 2010 at 15:33

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.