sed experts. Help
Glenn R Williams
gloonie at earthlink.net
Thu Oct 23 17:15:32 UTC 2008
Rick,
You just have to escape both the asterisks and the forward slashes, since they
are metacharacters to sed. This should work:
sed -i "/^<?php \/\*\*\/eval(base64_decode(/d" *.php
Glenn
On Thursday 23 October 2008 13:00:51 Rick Knight wrote:
> 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
--
Glenn R Williams
-------------------------
Bildiğin ayranı bilmediğin yoğurda değişme
-- Atasöz
More information about the kubuntu-users
mailing list