How to mass Search & Replace in text files.
Robert P. J. Day
rpjday-L09J2beyid0N/H6P543EQg at public.gmane.org
Fri May 1 14:33:39 UTC 2009
On Fri, 1 May 2009, Alex Beamish wrote:
> On Fri, May 1, 2009 at 10:26 AM, Lance F. Squire <lance-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org> wrote:
> > One of the sites on my server has been infected with some malicious Java
> > Script.
> >
> > I can locate all the files with:
> >
> > grep "Bad JS" `find . -name "*.html"`
> >
> > Is there a way to modify this to replace the "Bad JS" with ""?
> >
> > Or a find variant?
>
> The classic tool for doing this is sed .. but you could also use perl
> -ie 's/Bad JS//' *.html
or, recursively,
$ perl -pi -e 's/fred/barney/' $(find . -name "*.html")
or some variation thereof.
rday
--
========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA
Linux Consulting, Training and Annoying Kernel Pedantry.
Web page: http://crashcourse.ca
Linked In: http://www.linkedin.com/in/rpjday
Twitter: http://twitter.com/rpjday
========================================================================
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list