macos 通过 cURL 保存文件时,有没有办法给出特定的文件名?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9744973/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:58:57  来源:igfitidea点击:

Is there a way to give a specific file name when saving a file via cURL?

macoscurlterminal

提问by iveytron

I am pulling files using curl in the mac OS X terminal and want to give them different names. Is there a way to specify a name, such as a "save as" function when using curl?

我在 mac OS X 终端中使用 curl 提取文件并想给它们不同的名称。有没有办法在使用 curl 时指定名称,例如“另存为”功能?

回答by simonnordberg

Either use the -ooptionor its alias --output, or redirect shell output to the file of choice by using >.

使用该-o选项或其别名--output,或者使用>.

curl -o /path/to/local/file http://url.com
curl http://url.com > /path/to/local/file

If you want to preserve the original file name from the remote server, use the -Ooptionor its alias --remote-name.

如果要保留来自远程服务器的原始文件名,请使用该-O选项或其别名--remote-name

curl -O http://url.com/file.html 

Stores the output from the remote location in the current directory as file.html.

将远程位置的输出存储在当前目录中作为 file.html。

回答by Tonny Madsen

curl -o <name> <url>seems to do the trick..

curl -o <name> <url>似乎可以解决问题..

HINT: You can also try with man curl...

提示:您也可以尝试man curl...