通过 cURL 保存文件时,有没有办法给出特定的文件名? [英] Is there a way to give a specific file name when saving a file via cURL?

查看:40
本文介绍了通过 cURL 保存文件时,有没有办法给出特定的文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

推荐答案

要么使用 -o 选项 或其别名 --output,或使用 > 将 shell 输出重定向到选择的文件.

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

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

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

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

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

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

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

这篇关于通过 cURL 保存文件时,有没有办法给出特定的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆