I have nearly 100 HTML files that uses the <tt>
tag to markup inline code which I'd like to change to the more meaningful <code>
tag. I was thinking of doing something on the order of a massive sed -i 's/<tt>/<code>/g'
command but I'm curious if there's a more appropriate industrial mechanism for changing tag types on a large HTML tree.
views:
66answers:
3If your are on a linux environment then sed
is very easy, short, and fast way to do it.
Corrected command :
SAVEIFS=$IFS
IFS="\n"
for f in `find . -name "*.htm"` do sed -i 's/tt>/code>/g' "$f" ;done
IFS=$SAVEIFS
Some text editors or IDE also allow you to do a search and replace in directories with a filter on filename.
Hi,
For one time performance of such tasks I use UltraEdit on Windows. UE has a find and replace in files function that works great for this. I point it at the top of the directory tree containing the files I want to change, tell it to process sub-directories, give it the extension of the files I want to change, tell it what to change and what to change it to and go.
If you have to script this in linux, then I think the sed solution or a perl / php script will work great.
The nicest thing you may do is to use
xmlstartlet:
xml ed -r //b -v code
It is freaky powerful. See http://xmlstar.sourceforge.net/, http://www.ibm.com/developerworks/library/x-starlet.html