在 FTP 客户端中使用 grep 和 ls?

发布于 2024-08-08 08:22:23 字数 141 浏览 3 评论 0原文

我如何在 FTP 客户端中使用 grepls...

我的意思是如果我想找到一些可以使用的特定文件:

 ls -l | grep pattern

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

衣神在巴黎 2024-08-15 08:22:23

对于通常的 Unix 命令行交互式 ftp,一种方法是:

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

即,首先将 dir 结果放入本地文件,然后在本地运行 grep。顺便说一句,这可以让您在支付一次 dir 数据传输费用后运行多个 grep;-)。

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

琉璃繁缕 2024-08-15 08:22:23

lftp 可以,就像您输入的方式一样。

lftp can, exactly the way you typed.

清眉祭 2024-08-15 08:22:23

在 Windows 上,您可以使用任何协议(包括 FTP)的 WinSCP 脚本 来执行此操作:

winscp.com /command ^
    "open ftp://username:[email protected]" ^
    "ls /path/*.txt" ^
    "exit"

参考:
https://winscp.net/eng/docs/scripting
https://winscp.net/eng/docs/scriptcommand_ls

On Windows, you can do this with WinSCP scripting for any protocol, including the FTP:

winscp.com /command ^
    "open ftp://username:[email protected]" ^
    "ls /path/*.txt" ^
    "exit"

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

心欲静而疯不止 2024-08-15 08:22:23

您可以将 sftp 文件夹挂载到有权使用 grep 或任何工具的主机。

You can mount an sftp folder to a host where you have permissions to use grep or any tool.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文