carlf Posted March 24, 2008 Share Posted March 24, 2008 I have a site with MANY (over 30,000) directories with 15 php pages in each. I need to search the whole site and replace the string <-- with <?-- . Any suggestions? I can do it on my local PC, but I have spent over 50 hours uploading directories and do not want to start over, if I can help it. Link to comment https://forums.phpfreaks.com/topic/97606-search-site-and-replace-a-string-on-a-big-site/ Share on other sites More sharing options...
joshgarrod Posted March 24, 2008 Share Posted March 24, 2008 The only thing I can think of to do is to use DreamWeaver's extended search and replace tool. Link to comment https://forums.phpfreaks.com/topic/97606-search-site-and-replace-a-string-on-a-big-site/#findComment-499398 Share on other sites More sharing options...
trq Posted March 24, 2008 Share Posted March 24, 2008 Not tested, but this bash script (assuming your on Linux) should go close. Run it from the root of the site. for f in $(ls -r *.php) ; do sed -e -i 's/<--/<?--/' "$f" ; done Link to comment https://forums.phpfreaks.com/topic/97606-search-site-and-replace-a-string-on-a-big-site/#findComment-499399 Share on other sites More sharing options...
LemonInflux Posted March 24, 2008 Share Posted March 24, 2008 You could also write a str_replace script in PHP? Can't think of it off the top of my head, but you'd need a recursive function to list the directory (recursive because you might have directories within directories), then foreach file open and str_replace. Link to comment https://forums.phpfreaks.com/topic/97606-search-site-and-replace-a-string-on-a-big-site/#findComment-499400 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.