Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 12th Sep 2009, 03:51 PM   #1
The Wandering Businessman
War Room Member
 
Chris Ramsey's Avatar
 
Join Date: 2008
Location: The Globe
Posts: 1,417
Thanks: 161
Thanked 957 Times in 221 Posts
Default
Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

Hey Warriors,

Looks like my server has been hacked again. Ugh.

Anyway, I need to get my hands on a recursive search and replace script in PHP or PERL.

I could write one myself, but frankly, I'm sure there's a million of them out there.

If you know of one with good documentation, please list it. I need to get this taken care of ASAP.

Thanks.

Chris Ramsey is offline  
Unread 12th Sep 2009, 03:58 PM   #2
Advanced Warrior
War Room Member
 
TristanPerry's Avatar
 
Join Date: 2009
Location: Cardiff, United Kingdom
Posts: 760
Thanks: 159
Thanked 144 Times in 99 Posts
Default
Re: Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

Ultraedit has this. Can use regular expressions for the search and replaces.

Not sure if it goes through multiple files though.

Dreamweaver (you could always download the trial) definitely does go through all files in a folder, though.

Plagiarism Guard - Protect Against Content Theft
TristanPerry is offline  
Unread 12th Sep 2009, 04:04 PM   #3
The Wandering Businessman
War Room Member
 
Chris Ramsey's Avatar
 
Join Date: 2008
Location: The Globe
Posts: 1,417
Thanks: 161
Thanked 957 Times in 221 Posts
Default
Re: Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

I'm hoping to avoid reg exp, first of all because I want to shoot myself when I use them, and secondly it's one string that I need to remove from every file on my server.

Originally Posted by TristanPerry View Post

Ultraedit has this. Can use regular expressions for the search and replaces.

Not sure if it goes through multiple files though.

Dreamweaver (you could always download the trial) definitely does go through all files in a folder, though.

Chris Ramsey is offline  
Unread 12th Sep 2009, 05:11 PM   #4
Advanced Warrior
War Room Member
 
TristanPerry's Avatar
 
Join Date: 2009
Location: Cardiff, United Kingdom
Posts: 760
Thanks: 159
Thanked 144 Times in 99 Posts
Default
Re: Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

You can use both UltraEdit's and Dreamweaver's search and replace normally (by string) too; I was just pointing out that they have powerful features (whereby you can use regexes) if needed.

But yeah, they're both suitable for a simple search and replace

Plagiarism Guard - Protect Against Content Theft
TristanPerry is offline  
Unread 12th Sep 2009, 05:33 PM   #5
The Wandering Businessman
War Room Member
 
Chris Ramsey's Avatar
 
Join Date: 2008
Location: The Globe
Posts: 1,417
Thanks: 161
Thanked 957 Times in 221 Posts
Default
Re: Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

Originally Posted by TristanPerry View Post

You can use both UltraEdit's and Dreamweaver's search and replace normally (by string) too; I was just pointing out that they have powerful features (whereby you can use regexes) if needed.

But yeah, they're both suitable for a simple search and replace
Thanks Tristan.

P.S. Good on you for the Firefly avatar

Chris Ramsey is offline  
The Following User Says Thank You to Chris Ramsey For This Useful Post:
Unread 12th Sep 2009, 06:02 PM   #6
VIP Warrior
War Room Member
 
ereadergold's Avatar
 
Join Date: 2008
Location: Montreal Canada
Posts: 2,390
Thanks: 1,017
Thanked 836 Times in 572 Posts
Blog Entries: 1
Default
Re: Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

UltraEdit would work great for this task.

Another fine choice is PS Pad, unlike UltraEdit it's a free text editor (to be fair you can download a free trial of UltraEdit):

editor PSPad - freeware HTML editor, PHP editor, XHTML, JavaScript, ASP, Perl, C, HEX editor

Bill
ereadergold is offline  
Unread 12th Sep 2009, 06:05 PM   #7
The Wandering Businessman
War Room Member
 
Chris Ramsey's Avatar
 
Join Date: 2008
Location: The Globe
Posts: 1,417
Thanks: 161
Thanked 957 Times in 221 Posts
Default
Re: Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

These sound good, but all the files are server-side, and I'd like to keep them there.

So, if I can find something I can run via SSH, that would be best. That's why I'd like one in PHP or PERL. BASH may even work well.

Chris Ramsey is offline  
Unread 12th Sep 2009, 09:22 PM   #8
VIP Warrior
 
mojojuju's Avatar
 
Join Date: 2005
Location: Potemkin Village
Posts: 1,724
Thanks: 745
Thanked 742 Times in 498 Posts
Default
Re: Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

This is what I do:

Code:
find ./ -type f | xargs sed -i 's/What you want to find/Whatever you want to replace it with/g'

:)
mojojuju is offline  
Unread 12th Sep 2009, 11:41 PM   #9
Warrior Member
 
Join Date: 2009
Posts: 27
Thanks: 2
Thanked 2 Times in 2 Posts
Default
Re: Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

I think I know what your problem is .... your PC is infected with a virus... Scan your entire PC with a good antivirus (QuickHeal,Avira) ...... also, some types of viruses delete the bottom part of the page.... so simple replacing may not work ....

I use lacehost.com for hosting (do not go by their site design) and they really are very helpful in these matters .....
Mr.Tambourine is offline  
Unread 13th Sep 2009, 01:21 AM   #10
HyperActive Warrior
War Room Member
 
Join Date: 2002
Posts: 136
Thanks: 113
Thanked 44 Times in 36 Posts
Default
Re: Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

Originally Posted by Chris Ramsey View Post

These sound good, but all the files are server-side, and I'd like to keep them there.

So, if I can find something I can run via SSH, that would be best. That's why I'd like one in PHP or PERL. BASH may even work well.
Check this page:
Recursive search and replace (with a combination of bash, find and perl)
(it's a tutorial with step by step info and code)

HTH
Carlos
CMartin is offline  
Unread 13th Sep 2009, 08:56 AM   #11
The Wandering Businessman
War Room Member
 
Chris Ramsey's Avatar
 
Join Date: 2008
Location: The Globe
Posts: 1,417
Thanks: 161
Thanked 957 Times in 221 Posts
Default
Re: Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

Originally Posted by Mr.Tambourine View Post

I think I know what your problem is .... your PC is infected with a virus... Scan your entire PC with a good antivirus (QuickHeal,Avira) ...... also, some types of viruses delete the bottom part of the page.... so simple replacing may not work ....

I use lacehost.com for hosting (do not go by their site design) and they really are very helpful in these matters .....
Yeah, the server got hit by something. The majority of the files now have a stupid one liner at the very bottom that attaches lots of virus's to whoever views the page.

Chris Ramsey is offline  
Unread 13th Sep 2009, 08:58 AM   #12
The Wandering Businessman
War Room Member
 
Chris Ramsey's Avatar
 
Join Date: 2008
Location: The Globe
Posts: 1,417
Thanks: 161
Thanked 957 Times in 221 Posts
Default
Re: Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

Originally Posted by mojojuju View Post

This is what I do:

Code:
find ./ -type f | xargs sed -i 's/What you want to find/Whatever you want to replace it with/g'
Thanks! I actually tried using something very similar to this, but I can't remember what the response was. It wasn't something good, cause the problem didn't go away.

I'll give this a shot real quick and see what happens.

Chris Ramsey is offline  
Unread 13th Sep 2009, 09:20 AM   #13
The Wandering Businessman
War Room Member
 
Chris Ramsey's Avatar
 
Join Date: 2008
Location: The Globe
Posts: 1,417
Thanks: 161
Thanked 957 Times in 221 Posts
Default
Re: Recursive Search And Replace
Share on: 
fb share twitter share gplus share more share

Originally Posted by Chris Ramsey View Post

Thanks! I actually tried using something very similar to this, but I can't remember what the response was. It wasn't something good, cause the problem didn't go away.

I'll give this a shot real quick and see what happens.
This is the error I was getting - and still am.

sed: can't read ./wp-content/plugins/post-thumb/STRUCTURE: No such file or directory
sed: can't read youtube.txt: No such file or directory
I get it for each file.

Chris Ramsey is offline  
Closed Thread


Bookmarks

Tags
recursive, replace, search


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 12:48 AM.