我试过了mget *
,但它只下载文件而不下载文件夹。有没有“全部下载”选项?
答案1
要递归检索目录,您需要使用get -r
指令。来自 SFTP(1) 的手册页:
get [-Ppr] remote-path [local-path]
Retrieve the remote-path and store it on the local machine. If the local path name is not specified, it is given the same name it has on the remote machine. remote-path may
contain glob(3) characters and may match multiple files. If it does and local-path is specified, then local-path must specify a directory.
If either the -P or -p flag is specified, then full file permissions and access times are copied too.
If the -r flag is specified then directories will be copied recursively. Note that sftp does not follow symbolic links when performing recursive transfers.
如果这意味着从计划作业运行,则需要将这些命令添加到批处理文件中并使用该-b
选项。
答案2
也许最好的方法是使用 wget 或 curl。两者都可以在 CentOS 存储库中找到。两者都是瑞士军刀程序,您需要阅读手册页,看看哪一个感觉更自然。