gpt4 book ai didi

bash - 使用 cURL 下载目录中的所有文件

转载 作者:行者123 更新时间:2023-11-29 08:47:54 24 4
gpt4 key购买 nike

我正在使用 cURL 尝试下载特定目录中的所有文件。

这是我的文件列表:

enter image description here

我尝试在 bash 脚本中做:iiumlabs.[].csv.pgpiiumlabs* 我猜 curl 在通配符上并不大。

curl -u login:pass ftp.myftpsite.com/iiumlabs* -O

问题:如何使用 cURL 下载此目录的文件?

最佳答案

如果你不习惯 curl ,你可能想使用 wget在递归模式下但将其限制为一级递归,请尝试以下操作;

wget --no-verbose --no-parent --recursive --level=1 \
--no-directories --user=login --password=pass ftp://ftp.myftpsite.com/
  • --no-parent :递归检索时永远不要提升到父目录。
  • --level=depth : 指定递归最大深度级别深度。默认最大深度为五层。
  • --no-directories :递归检索时不创建目录层次结构。
  • --delete-after : 如果下载后需要删除文件可以加上。
  • --no-host-directories :直接在“.”中下载当前文件夹,而不是创建以域命名的目录。
  • --no-clobber : 跳过会下载到现有文件的下载
  • --continue : 继续获取部分下载的文件以提高稳定性
  • 结合cd :定义目标目录

所以这个示例看起来像下面这样:

cd /home/destination/folder \
&& wget --no-verbose --no-parent --recursive --level=1 \
--no-directories --no-host-directories \
--no-clobber --continue \
--user=login --password=pass ftp://ftp.myftpsite.com/

关于bash - 使用 cURL 下载目录中的所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11783280/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com