Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: [gentoo-user] [OT]batch processing html files

From: Alan McKinnon <alan.mckinnon(at)gmail.com>
Date: Wed Apr 30 2008 - 12:02:38 EDT


On Wednesday 30 April 2008, Matthew R. Lee wrote:
> I have a folder full of .html files and I need to go through and
> replace in each and every one of them a couple of bits of info. I
> know I can do this using the following from the command line:
> sed 's/VV, ppp-ppp/81, 51-67/' file.html > newfile.html | mv
> newfile.html file.html
> Problem is I need to do this on nearly 200 files. I assume it could
> be done with a script, but I have zero experience in writing scripts.
> I've looked through a few how-to's but haven't found anything I
> understand sofar. I want to learn how to script, but my Prof want's
> this done yesterday as the associated paper has just been published.
> Cheers
> Matt

bash to the rescue! try "for":

for n in *html ; do sed 's/VV, ppp-ppp/81, 51-67/' $n > newfile.html ; mv > newfile.html $n ; done

That assumes that every html file in the current dir that contains VV must have it changed. Adapt as needed :-)

Somehow somewhere you can accomplish what you want in one line with a suitable combination of locate, find, grep, for, xargs, sed and awk

-- 
Alan McKinnon
alan dot mckinnon at gmail dot com

-- 
gentoo-user@lists.gentoo.org mailing list
Received on Wed Apr 30 12:04:16 2008

This archive was generated by hypermail 2.1.8 : Sat Aug 02 2008 - 05:05:58 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library