有curl可能做
curl http://somedomain.com/originalfilename.tar.gz -o newfilename.tar.gz
curl http://somedomain.com/originalfilename.tar.gz -o /other/path/newfilename.tar.gz
Run Code Online (Sandbox Code Playgroud)
因此,-o可以重命名要下载的文件名,甚至定义其他路径目录来下载
现在,如果我想保留相同的文件名,则必须使用-O
curl http://somedomain.com/originalfilename.tar.gz -O
Run Code Online (Sandbox Code Playgroud)
因此下载了该originalfilename.tar.gz文件。
现在
问题
-O)并定义要下载的目录?就像是
curl http://somedomain.com/originalfilename.tar.gz -O <download to /some/path>
Run Code Online (Sandbox Code Playgroud)
因此对于 Shell 脚本来说,脚本可以在任何地方执行。我想originalfilename.tar.gz明确下载该文件/some/path
Kus*_*nda 10
您可以使用该选项指定要写入的文档的目录路径--output-dir。
那是,
curl -O --output-dir /some/path "$URL"
Run Code Online (Sandbox Code Playgroud)
从curl手册中:
--output-dir <dir>
This option specifies the directory in which files should be
stored, when --remote-name or --output are used.
The given output directory is used for all URLs and output
options on the command line, up until the first -:, --next.
If the specified target directory does not exist, the operation
will fail unless --create-dirs is also used.
If this option is used multiple times, the last specified
directory will be used.
Example:
curl --output-dir "tmp" -O https://example.com
See also -O, --remote-name and -J, --remote-header-name. Added
in 7.73.0.
Run Code Online (Sandbox Code Playgroud)