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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityI 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?
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.
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