tags:

views:

585

answers:

2

How could I use grep and ls in ftp client...
I mean if I want to find some specific file I could use,

ls -l | grep pattern


thanks.
jcyang.

+1  A: 

With the usual Unix commandline interactive ftp, one approach is:

Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir . foobar
output to local-file: foobar [anpqy?]? y
500 Unknown command
227 Entering Passive Mode (62,149,140,15,195,159)
150 Accepted data connection
 11966       5.26 KB/s 
226-Options: -a -l 
226 156 matches total
ftp> !grep con foobar
-rwxr-xr-x    1 11050207   users          911007 Sep 13  2007 accu_pyconc.pdf
-rwxr-xr-x    1 11050207   users         9805405 Mar 25  2009 pycon_abst.pdf

i.e., get the dir results into a local file first, then run grep locally. Incidentally, this lets you run multiple greps after paying for just one dir data transfer;-).

Alex Martelli
Thanks.So is it means that no ftp client support shell like feature e.g. pipe or even build-in call(I mean without '!') to other command like grep...
Jichao
Alex Martelli
A: 

lftp can, exactly the way you typed.

ephemient
Thanks.It is exactly what i want.
Jichao