
有时候,我们通过curl下载文件时,希望文件保存时使用该文件在服务器端的文件名和时间戳,那么可以使用-O和-R两个选项。如下:
curl -R -O https://mirrors.tencent.com/tlinux/4.4/images/qcow2/x86_64/TencentOS-Server-GenericCloud-4.4-20251223.0.x86_64.qcow2可以通过man curl命令查看帮助文档,了解这2个选项的含义和用法。
-O选项,保存到本地文件,文件名使用服务器端的文件名。
-O, --remote-name
Write output to a local file named like the remote file we get. (Only the file part of the remote file is used, the path is cut
off.)
The file is saved in the current working directory. If you want the file saved in a different directory, make sure you change
the current working directory before invoking curl with this option or use --output-dir.
The remote file name to use for saving is extracted from the given URL, nothing else, and if it already exists it is overwrit‐
ten. If you want the server to be able to choose the file name refer to -J, --remote-header-name which can be used in addition
to this option. If the server chooses a file name and that name already exists it is not overwritten.
There is no URL decoding done on the file name. If it has %20 or other URL encoded parts of the name, they end up as-is as file
name.
You may use this option as many times as the number of URLs you have.
-O, --remote-name can be used several times in a command line
Example:
curl -O https://example.com/filename
See also --remote-name-all, --output-dir and ‐J, --remote-header-name.
-R选项,保存到本地文件,使用服务器端的文件时间戳。
-R, --remote-time
Makes curl attempt to figure out the timestamp of the remote file that is getting downloaded, and if that is available make the
local file get that same timestamp.
Providing -R, --remote-time multiple times has no extra effect. Disable it again with --no-remote-time.
Example:
curl --remote-time -o foo https://example.com
See also ‐O, --remote-name and ‐z, --time-cond.
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。