sed experts. Help

Jonas Norlander jonorland at gmail.com
Thu Oct 23 18:45:59 BST 2008


2008/10/23 Rick Knight <rick_knight at rlknight.com>:
> There is a typo in my original post. The line of code I need to remove
> begins with...
>
> <?php /**/eval(base64_decode(
>
> Note the addition of /**/ to the line. When I add this to the sed
> command I get an error...
>
> sed: -e expression #1, char 15: unknown option to `s'
>
> I assume this means I need to escape the /**/ somehow but when I pu \ in
> front of / I get a different error...
>
> sed: -e expression #1, char 40: Invalid preceding regular expression
>
> How do I get past this?
>
> Thanks,
> Rick
>

You don't have to use the '/' as a delimiter in sed, you can use other
character like '@'. So if you searching strings with many '/' it will
be easier to read the sed script. So the script would be something
like this (Warning untested):

find <dir> -type f  -iname *.php -exec sed -i.bak '@^<?php
\/\*\*\/eval(base64_decode(.*@d' {} \;

/ Jonas



More information about the kubuntu-users mailing list