Results 1 to 3 of 3
I have (for better or worse) inherited a website designed with Dreamweaver (uuuuuuuuuugh). The style of Dreamweaver is kind of ok, since instead of making a process heavy dynamic file ...
- 08-09-2008 #1Just Joined!
- Join Date
- Dec 2006
- Posts
- 17
changing a line of code in many hundreds of files
I have (for better or worse) inherited a website designed with Dreamweaver (uuuuuuuuuugh). The style of Dreamweaver is kind of ok, since instead of making a process heavy dynamic file to be run through every time it wants to load a page, it just makes a billion .htm files that you can serve at the speed of light and (I'm assuming) easily manage through the Dreamweaver application. I, however, do not use Dreamweaver and never will, as for one, I use Linux and two, I HATE the code Dreamweaver makes, so dirty and disgusting.
The problem here is that if I want to change something like one of the global navigation buttons, I would have to go around to EVERY .htm file and change it.
I've been trying to find a way to do exactly that with a nice bash/perl script. But the closest I have come so far is:
find website_directory/ -type f | for i in *.htm ; do cat $i | grep "code string for button" ; done
This bash script is incomplete, and in fact doesn't even really work. I'm kind of lost here as to what command can do a "replace text inside of a file", but I guess I'm at least somewhat on the right track?
Any suggestions?
- 08-09-2008 #2Linux User
- Join Date
- Jun 2007
- Posts
- 318
Something like this:
This command searches website_directory (and no sub-directories) for files that end with '.html' and uses sed (stream editor) to replace a string using the 's' (substitute) command.Code:find website_directory -maxdepth 1 -type f -name '*.html' \ -print -exec sed -i 's/code string for button/new string/' {} \;
- 08-11-2008 #3Just Joined!
- Join Date
- Dec 2006
- Posts
- 17
@vsemaska: You're my new hero. Thank you very much!


Reply With Quote