-o, --output <file>
常规操作一:把一个请求的响应写入单个文件中
curl www.baidu.com --output "baidu.txt"
将会把百度首页的内容放入文件baidu.txt,baidu.txt在执行命令的当前目录生成。
常规操作二:把多个请求的响应写入多个文件中(单个集合变量)
curl -v https://test.test.com/ai-doc/FACE/{6k37c1nva,Yk37c1o30} --output "file_#1abc.txt"
将会把两个接口https://test.test.com/ai-doc/FACE/Okg7edktq,https://test.test.com/ai-doc/FACE/6k37c1nva的内容分别存入file_Okg7edktqabc.txt,file_Yk37c1o30abc.txt文件中,大括号相当于集合,里面的元素会替换掉指定的文件名中的#1字符。
注意:此命令在linux下执行{}需要转义,即\{.....\}
常规操作三:把多个请求的响应写入多个文件中(单个数组变量)
curl https://test.test.com/ai-doc/FACE/Yk37c1o3[0-5] --output "b_#1.txt"
将会把六个接口:
- https://test.test.com/ai-doc/FACE/Yk37c1o30
- https://test.test.com/ai-doc/FACE/Yk37c1o32
- https://test.test.com/ai-doc/FACE/Yk37c1o33
- https://test.test.com/ai-doc/FACE/Yk37c1o34
- https://test.test.com/ai-doc/FACE/Yk37c1o35
- https://test.test.com/ai-doc/FACE/Yk37c1o36
的响应分别存入以下文件
- b_0.txt
- b_1.txt
- b_2.txt
- b_3.txt
- b_4.txt
- b_5.txt
常规操作三:把多个请求的响应写入多个文件(多个集合、多个数组变量)
curl http://{site,host}.baidu.{one,two}.host[1-5].sina[0-5].com -o "#1_#2_#3_#4"
请自行演示。
- Write output to <file> instead of stdout.
- If you are using {} or [] to fetch multiple documents, you can use '#' followed by a number in the <file> specifier. That
variable will be replaced with the current string for the URL being fetched. Like in:
curl http://{one,two}.site.com -o "file_#1.txt"
or use several variables like:
curl http://{site,host}.host[1-5].com -o "#1_#2" - You may use this option as many times as the number of URLs you have.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。