[英]Unclear curl option -o <filename#1>. What exactly does '#' do?
我想下載幾個文件,並使用Curl在其文件名中使用變量。
例如: curl https://curl.haxx.se/docs/{companies,whodocs}.html -o "file_#1.txt"
我正在使用curl 7.61.1
從Curl手冊頁中,我可以使用一些字符串替換文件名中的#number
。 所以,我認為我應該得到file_companies.txt
和file_whodocs.txt
但在我的情況下,該命令只有在下載file_#1.txt
並打印第二個文件到標准輸出(如無-o <filename>
)。 所以我想知道如何使用此選項。
任何解釋將不勝感激。 謝謝。
Bash的大括號擴展被擋住了。 您應該引用{ ... }
。
$ curl 'https://curl.haxx.se/docs/{companies,whodocs}.html' -o "file_#1.txt"
[1/2]: https://curl.haxx.se/docs/companies.html --> file_companies.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 29316 100 29316 0 0 5097 0 0:00:05 0:00:05 --:--:-- 7540
[2/2]: https://curl.haxx.se/docs/whodocs.html --> file_whodocs.txt
100 2528 100 2528 0 0 23849 0 --:--:-- --:--:-- --:--:-- 23849
{companies,whodocs}
通過bash擴展為兩個參數:
$ echo curl https://curl.haxx.se/docs/{companies,whodocs}.html -o "file_#1.txt"
curl https://curl.haxx.se/docs/companies.html https://curl.haxx.se/docs/whodocs.html -o file_#1.txt
那不是你想要的。 您想按原樣通過{...}
來卷曲。 您需要引用它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.