sed experts. Help

Glenn R Williams gloonie at earthlink.net
Thu Oct 23 17:20:15 UTC 2008


To add a backup file, just put the suffix you want after the "-i" option. In 
this example, I have sed name backup files with a ".bak" suffix:

sed -i.bak "/^<?php \/\*\*\/eval(base64_decode(/d" file*.txt

Glenn

On Thursday 23 October 2008 13:04:17 Rick Knight wrote:
> Glenn R Williams wrote:
> > Jared,
> >
> > sed -i '/^<?php eval(base64_decode(.*/d' *.php
>
> can I add .bak to this command to have it backup the files?
>
> > will update all files in place, deleteing all lines beginning with:
> >
> > <?php eval(base64_decode(
>
> This should have been <?php /**/eval(base64_decode (my mistake). How
> would I add /**/ to this command?
>
> > Make a backup first, since this is a very poerful command!
> >
> >
> > HTH,
> >
> > Glenn
> >
> > On Thursday 23 October 2008 00:54:10 Jared Greenwald wrote:
> >> there's nothing that says you need to do all the files in one sed
> >> command, right?
> >>
> >> something like this should work...
> >>
> >> find <dir> -type f -exec sed -i.bak 's/^<?php eval(base64_decode(.*.$//'
> >> {} \;
> >>
> >> ...Not only will it do all the line removal, it will also make backups
> >> (as <file>.bak) so if you screw up you will have the original files to
> >> revert.
> >>
> >> -Jared
> >>
> >> On Thu, Oct 23, 2008 at 12:22 AM, Rick Knight <rick_knight at rlknight.com>
> >
> > 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
> >>>
> >>> --
> >>> kubuntu-users mailing list
> >>> kubuntu-users at lists.ubuntu.com
> >>> Modify settings or unsubscribe at:
> >>> https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
>
> Thanks,
> Rick

-- 
Glenn R Williams
-------------------------
The footprints of occupation are beautiful when they are in a museum
	-- Mahmoud Darwish





More information about the kubuntu-users mailing list