Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can you search and replace text in multiple files on an FTP server?

Basically I need to change the Google Analytics information on a bunch of plain old HTML pages and I'm wondering if there is a way to do it without having to download all of the files, do the search and replace locally and then FTP them back.

share|improve this question
6  
Don't forget that FTP is only a file transfer protocol, so it's meant for transferring files to your computer and back. Even when you view a remote file, it is temporarily transferred to your computer before. Is there any reason why you'd not want to download the files and sync them back? –  slhck Jul 13 '11 at 20:54
    
What if the site you are searching has more than 50 folders full of 10-20 php files in it? Downloading every single file and then find and replace? Really? And mapping of this drive is not allowed, we are only allowed to view through ftp because of security. :/ –  jlg Sep 5 '12 at 13:30
    
If the FTP is for "security", are you sure it isn't Sftp? Can you get SSH access? –  G Koe Mar 28 at 1:58
add comment

4 Answers

As the comment says, ftp doesn't allow this. You probably really want the 'download all, replace, upload back'.

The best I can think of is an editor that understands ftp. Behind the scenes, it's downloading the file, editing it locally, and then uploading, but maybe this 'invisible background ftp' is what you want. I don't know if any do multiple files though. There are individual programs that can do this, and I think any true KDE editor (e.g. kate) can do this through KIOSlaves.

share|improve this answer
add comment

Windows can map a ftp site to a drive letter, at least in XP, Linux has curlftpfs, which can mount a ftp site.

Either options is really downloading and updating in background after any file is edited. Not the ideal solution. I'd personally write a script to do the updates. However, if it's only to be done once, use what ever might work.

share|improve this answer
add comment

If FTP is the only mode of access, I don't see any other way than to download all the files and make the changes locally.

In Windows, an easy tool to use is Notepad++. The Find/Replace function lets you span over all open files, or you can point it to a directory of files and have it carry out your find/replace operation on all files in the directory.

Once done, upload again via FTP.

share|improve this answer
add comment

You may be able to do this with putty if you have telnet access to the server as well as ftp. Then, depending on if you are on a linux or windows server, you'd use the appropriate command line text editor to modify the files.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.