sed experts. Help

Rick Knight rick_knight at rlknight.com
Thu Oct 23 17:00:51 UTC 2008


Jared Greenwald wrote:
> On Thu, Oct 23, 2008 at 7:57 AM, Alexander Smirnov
> <alexander.v.smirnov at gmail.com> wrote:
>   
>> Rick Knight wrote:
>>     
>>> Sed experts,
>>>
>>> I have a bunch of php scripts, over 1000, that all need to have 1 line
>>> removed. The line begins with...
>>>
>>> <?php eval(base64_decode(
>>>
>>> and is at the top of each file. How would I construct a sed command to
>>> remove this line from every file in a directory and it's subs?
>>>
>>> Thanks,
>>> Rick
>>>
>>>
>>>       
>> why sed? you can use excluding option of grep:
>> $grep - v  "<?php eval(base64_decode( "
>> will match every line but not mentioned.
>>     
>
> Sed (with the -i option) has the added benefit of editing in-place.
>
>   
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




More information about the kubuntu-users mailing list