Dennis Carr (dennisthetiger) wrote in geek_furs,
Dennis Carr

How to edit multiple HTML files in one fell swoop?

Hey, gang.

Here's the background. I have literally hundreds of HTML files, all named index.html, that I am about to transition from one server to another. The syntax in the files are all pretty much identical, but the catch is that they are all in a rather large directory tree. The site, for point of reference, is here, and I'm transitioning the files to here. All files are on two different Linux boxes - is on Debian, and is on some sort of Red Hat derivative.

The ultimate goal, eventually, is to implement CSS in all the pages, but for the time being, the job here is to edit the stuff on Northarc so it coincides with the tree on Chez Vrolet.

Note, my desktop at home is running Debian Lenny.

There are two ways I can do this. One is, of course, to edit each HTML file individually - which, with around 500 files on the source server, is going to take a LOOOOOOOOONG time. The other way, of course, is using sed or perl or something. The problem is that I'm not very well versed in sed, and I don't know perl. Yet. In this context, I'm looking for a means to do this on the command line - neither of the servers have X enabled.

The quick way I have is something like this:

$ for foo in `find . -name '*.html'
> do
> #(something that alters all these files)
> done

...I'm just missing what goes on that commented line in the for loop.

So this said, does anyone have a good way to do this from the terminal?
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded