1 |
On Wednesday 30 April 2008, Matthew R. Lee wrote: |
2 |
> I have a folder full of .html files and I need to go through and |
3 |
> replace in each and every one of them a couple of bits of info. I |
4 |
> know I can do this using the following from the command line: |
5 |
> sed 's/VV, ppp-ppp/81, 51-67/' file.html > newfile.html | mv |
6 |
> newfile.html file.html |
7 |
> Problem is I need to do this on nearly 200 files. I assume it could |
8 |
> be done with a script, but I have zero experience in writing scripts. |
9 |
> I've looked through a few how-to's but haven't found anything I |
10 |
> understand sofar. I want to learn how to script, but my Prof want's |
11 |
> this done yesterday as the associated paper has just been published. |
12 |
> Cheers |
13 |
> Matt |
14 |
|
15 |
bash to the rescue! try "for": |
16 |
|
17 |
for n in *html ; do sed 's/VV, ppp-ppp/81, 51-67/' $n > newfile.html ; |
18 |
mv > newfile.html $n ; done |
19 |
|
20 |
That assumes that every html file in the current dir that contains VV |
21 |
must have it changed. Adapt as needed :-) |
22 |
|
23 |
Somehow somewhere you can accomplish what you want in one line with a |
24 |
suitable combination of locate, find, grep, for, xargs, sed and awk |
25 |
|
26 |
-- |
27 |
Alan McKinnon |
28 |
alan dot mckinnon at gmail dot com |
29 |
|
30 |
-- |
31 |
gentoo-user@l.g.o mailing list |