如何通过FTP在Linux上递归下载文件夹[关闭](How to recursively download a folder via FTP on Linux [closed])

编程入门 行业动态 更新时间:2024-10-22 21:37:09
如何通过FTP在Linux上递归下载文件夹[关闭](How to recursively download a folder via FTP on Linux [closed])

我正在尝试使用命令行ftp客户端ftp文件夹,但到目前为止,我只能使用'get'获取单个文件。

I'm trying to ftp a folder using the command line ftp client, but so far I've only been able to use 'get' to get individual files.

最满意答案

你可以依靠通常处理ftp的wget(至少在我自己的经验中)。 例如:

wget -r ftp://user:pass@server.com/

您还可以使用适合镜像的-m 。 它目前等效于-r -N -l inf 。

如果凭证详细信息中有一些特殊字符,则可以指定--user和--password参数以使其正常工作。 具有特定字符的自定义登录示例:

wget -r --user="user@login" --password="Pa$$wo|^D" ftp://server.com/

编辑由@asmaier指出,注意即使-r用于递归,它的默认最大级别为5:

-r --recursive Turn on recursive retrieving. -l depth --level=depth Specify recursion maximum depth level depth. The default maximum depth is 5.

如果您不想错过子目录,请更好地使用镜像选项-m :

-m --mirror Turn on options suitable for mirroring. This option turns on recursion and time-stamping, sets infinite recursion depth and keeps FTP directory listings. It is currently equivalent to -r -N -l inf --no-remove-listing.

You could rely on wget which usually handles ftp get properly (at least in my own experience). For example:

wget -r ftp://user:pass@server.com/

You can also use -m which is suitable for mirroring. It is currently equivalent to -r -N -l inf.

If you've some special characters in the credential details, you can specify the --user and --password arguments to get it to work. Example with custom login with specific characters:

wget -r --user="user@login" --password="Pa$$wo|^D" ftp://server.com/

EDIT As pointed out by @asmaier, watch out that even if -r is for recursion, it has a default max level of 5:

-r --recursive Turn on recursive retrieving. -l depth --level=depth Specify recursion maximum depth level depth. The default maximum depth is 5.

If you don't want to miss out subdirs, better use the mirroring option, -m:

-m --mirror Turn on options suitable for mirroring. This option turns on recursion and time-stamping, sets infinite recursion depth and keeps FTP directory listings. It is currently equivalent to -r -N -l inf --no-remove-listing.

更多推荐

本文发布于:2023-08-07 21:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465554.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:递归   文件夹   Linux   FTP   closed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!