Using grep and ls in an FTP client?

How can I use grepit lsin an FTP client ...

I mean, if I want to find a specific file that I could use:

 ls -l | grep pattern
+3
source share
3 answers

lftp may, exactly as you typed.

+3
source

With the usual interactive Unix ftp interface, one approach:

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

ie, first run the search results in a local file, then run grep locally. By the way, this allows you to run multiple greps after paying only one data transfer dir; -).

+6
source

Windows WinSCP , FTP:

winscp.com /command ^
    "open ftp://username:password@example.com" ^
    "ls /path/*.txt" ^
    "exit"

References:
https://winscp.net/eng/docs/scripting
https://winscp.net/eng/docs/scriptcommand_ls

0
source

Source: https://habr.com/ru/post/1720978/


All Articles