I'm looking to find and replace a string in all HTML files within a certain directory, including subdirectories. Normally, I would play with this a little to get it to work, but I can't mess this up, so I'm going to ask here.
Basically, I want to find "<title>" in all *.htm* files (to include .htm and .html) and replace it with "<title>My Website Name - ". I'm doing a bit of search engine optimization. How should I write a shell script to do this?
Okay, this works great on my local machine (running linux). But after logging into the web server, I find the sed on that machine doesn't have the -i switch. What should I do?
Vidyadhar85, your code didn't seem to work for me. For one, it didn't look in any deeper directories (fixed with grep -lr) and also, the temp file is always blank, so it basically erases the contents of the file. How do I fix it?
Actually, I just noticed that myself, but I still seem to be having problems. For some reason when I try to search recursively through the directory, it won't work for *.htm*, but it will for just *. See the output I listed below. What gives?
thats because as you see in grep man page whenever you use -r or -R option it expect a dir if you give * it will go through the child dir also but when you specify a file or group of file it will search in . i.e home dir only