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?


5 Answers 5


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.


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

  • 2
    As with everything which is mount based, this implies that you will transfer the whole data to your own host. Apr 2, 2012 at 12:27
  • 1
    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, 2012 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.


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

By using lftp

First grab everything from ftp to file

$ lftp http://downloads.site.com/sources> find . > sources-list.txt

Next perform grep on file:

$ grep FILE sources-list.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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