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

Reply via email to