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
Is there a way to give a specific file name when saving a file via cURL?
提问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 -o
optionor 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 -O
optionor 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
...