Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried searching for similar command in ncftp (actually this is the only terminal ftp client I used) and I didn't find it.

What's the way (if possible at all) to use grep command on remote server, to search for strings in files?

share|improve this question
Also related: Search Within Files On Remote FTP Site - Stack Overflow – sdaau Mar 2 '14 at 18:18

The standard ftp protocol does not allow it (You can check the list of commands). So you would have to download everything just to be able to grep on it.

share|improve this answer

You can use curlftpfs to mount remote ftp as local disk and manipulate with files as on your local machine.

share|improve this answer
As with everything which is mount based, this implies that you will transfer the whole data to your own host. – Stéphane Gimenez Apr 2 '12 at 12:27
Yes it will. But it also depends on task you need to perform. When you need grep something in the most cases you can ignore nontext files (and they won't be transfer) and maybe part of text files. So in this case your sum transfer size may be lower than in case you'll transfer the whole data from the remote site. – rush Apr 2 '12 at 12:45

You should localy mount the remote FTP directory to do this, however, be warned that all the files you grep will need to be downloaded for this operation.

SSH into the remote machine and run grep through there, if possible, to save bandwidth.

share|improve this answer

Assuming you are using simple ftp via command line, Use dir command with -Rl option to search recursively and copy it to a file and then search the file using grep, find or whatever way is supported on your OS.

ftp> dir -Rl education.txt
output to local-file: education.txt? y
227 Entering Passive Mode (9,62,119,15,138,239)
150 Opening ASCII mode data connection for file list
226 Transfer complete
share|improve this answer

Your Answer


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.