LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Find & replace script (?)

[ILUG] Find & replace script (?)

Lars Hecking lhecking at nmrc.ucc.ie
Mon Aug 23 12:43:27 IST 1999


> THE PROBLEM
> The problem is that I am currently in the process of switching web servers.
> (Going with apache) Now the problem is that all the web pages have server
> specific tags in the html. These do not work under apache and I don't want
> them to either. Now what I want to do is one of the following:
> 1. I could leave the specifc tags alone and just write in my own (in this
> case I am call a ssi <!--#exec cmd="/path/to/command"--> that would be fine
> except I need to delete one line from all the files and add the above ssi
> tag. How do i do this with with a web site that has about 10,000 to 35,000
> documents.

 If the tag is the same in all documents:

$ for i in `find /foo/bar -name '*.html' -print` ; do mv ${i} ${i}.bak ; \
  sed 's,tag,replacement,g' ${i}.bak >${i} ; rm -f ${i}.bak ; done

 If not all documents need to be processed, one could wrap an

 if grep 'tag' ${i} >/dev/null 2>&1 ... fi

 around the mv ... sed ... rm ... sequence.

 If the tag contains a number of different special characters, it may be
 necessary to do the processing in more than one step, or even use
 temporary placeholders

 ... sed -s 's,xxx,yyy,g' -e 's,zzz,ttt,g' -e "s,yyy,uuu,g'

 If the tag is different in different files, it gets more complicated,
 and others might suggest perl ...

 You can email me directly if you need more help.





More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell