0

I am using teamsite version 6, all my pages are html and I have to make an update to rather a lot of pages on my site. I was looking to hopefully do a find and replace script that would update all instances to save time.

Is this possible and how would it be done?

  • You should explain a bit more what are your needs. What king of replacement do you need? Should the script be written in Java or any other language can be used? What is the OS? – Francisco Puga Jan 06 '12 at 11:52

2 Answers2

1

This should recursively check all files in your folder and replace oldstr with newstr:

find ./ -type f -exec sed -i 's/oldstr/newstr/' {} \;
Gaurav Gupta
  • 5,380
  • 2
  • 29
  • 36
  • Which file would I add this code to so that it will check the entire site? – user1054111 Jan 06 '12 at 12:14
  • Which file would I add this code to so that it will check the entire site? – user1054111 Jan 06 '12 at 12:14
  • var str="Welcome to Microsoft! "; str=str + "We are proud to announce that Microsoft has "; str=str + "one of the largest Web Developers sites in the world."; document.write(str.replace(/microsoft/gi, "W3Schools")); – user1054111 Jan 06 '12 at 12:15
0

I would run the command from the command line.

If it is a linux machine I would use the 'sed -i' option:

find .* -exec sed -i 's/Old_String/New_String/g' '{}' \;


If it is a solaris machine I would use the 'sed -i' option:

find .* -exec perl -pi -e 's/Old_String/New_String/g' '{}' \;