Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
    
add comment

3 Answers

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
add comment

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

share|improve this answer
2  
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
add comment

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
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.