Using grep and ls in FTP client?

不羁岁月 提交于 2020-01-13 13:04:42

问题


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

回答1:


lftp can, exactly the way you typed.




回答2:


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




回答3:


On Windows, you can do this with WinSCP scripting for any protocol, including the 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



来源:https://stackoverflow.com/questions/1618611/using-grep-and-ls-in-ftp-client

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!