[CS-FSLUG] I need a quick way to edit quite a few html documents

davidm at hisfeet.net davidm at hisfeet.net
Thu Jun 9 14:58:50 CDT 2011


First: Thank you all for trying to help me with this. I got to 
exploring Gedit, and was really surprised at what it can do.  I had 
thought that it was just a simple text editor. It can certainly make 
life easier.

But that command line with sed looks as if it ought to be the quickest 
way.  Here's what I did: I downloaded my website to my hard drive. Then 
I sorted through it and put all of the htm or html files in a separate 
directory.

here are the changes that need to be made:

old line:
<center><h4><a href="index.php" title="Our home page">Return to Home 
page.</a></h4></center>

new line:
<center><h4><a href="index2.htm" title="Our home page">Return to Home 
page.</a></h4></center>

second change:
old line:
(<a href="index.php" title="HisFeet.net Home Page.">Harvesting 
Harvesters</a>)</p>

(<a href="index2.htm" title="HisFeet.net Home Page.">Harvesting 
Harvesters</a>)</p>

In both cases it appears to me that all that needs to be changed is 
"index.php" to "index2.htm" Near as I can tell that change in any place 
on any of my html files shouldn't make any negative difference. In fact 
I'm quite certain that it needs to be changed wherever it occurs.

  went to a terminal and changed directory to the directory where those 
*.htm? files are, and inserted this line after the "$" prompt.

I tried to do just a small subset (those *.html files that begin with 
the letter "g") Here's what I tried: (didn't get any errors, but also it 
didn't make the expected changes)

for file in g*.htm?; do sed -i 's/index.php/index2.htm/g' $file; done

I also tried it with the descrption of the files to change as being 
just *.htm and also *.html

I didn't try it as root - didn't know if it was safe to do so.  What am 
I missing? Or how have I messed up the command?

Dave










More information about the Christiansource mailing list