Bash 旋度选项不明确-o<;文件名#1>;。究竟什么是'#';做

Bash 旋度选项不明确-o<;文件名#1>;。究竟什么是'#';做,bash,shell,curl,Bash,Shell,Curl,我想下载几个文件,并使用Curl在文件名中使用变量 e、 g: curlhttps://curl.haxx.se/docs/{companys,whodocs}.html-o“file#1.txt” 我使用的是curl 7.61.1 从Curl手册页中,我发现文件名中的#number应该被一些字符串替换。因此,我假设我应该获取文件\u companys.txt和文件\u whodocs.txt,但在我的例子中,这个命令只是下载文件\u35; 1.txt,然后将第二个文件打印到stdout(就像没

我想下载几个文件,并使用Curl在文件名中使用变量

e、 g:
curlhttps://curl.haxx.se/docs/{companys,whodocs}.html-o“file#1.txt”

我使用的是curl 7.61.1

从Curl手册页中,我发现文件名中的
#number
应该被一些字符串替换。因此,我假设我应该获取
文件\u companys.txt
文件\u whodocs.txt
,但在我的例子中,这个命令只是下载
文件\u35; 1.txt
,然后将第二个文件打印到stdout(就像没有
-o
)。所以我想知道如何使用这个选项

如有任何解释,将不胜感激。谢谢。

碍事了。你应该引用
{…}

$ 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
bash将
{companys,whodocs}
扩展为两个参数:

$ 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

那不是你想要的。您希望按字面意思传递
{…}
以进行卷曲。你需要引用它。

你必须在每个URL中使用一个
-o
,我也不能让广告中的替换工作正常<代码>wgethttps://curl.haxx.se/docs/{companys,whodocs}.html可能是一个更好的选择。是的,我知道每个URL通常有一个
-o
,但在这种情况下,我必须指定所有文件名,并且不能使用变量替换。我认为,如果
{}
扩展位于URL的末尾,使用
wget
就可以了。根据CURL文档,它也应该在URL.YUP中间的某个地方工作,这显然是使用CURL所必须做的。不会在不同URL上遇到相同文件的问题。比如:
www.example.com/test/file.txt
www.example.com/test two/file.txt
?我相信默认情况下,它会创建
file.txt
file.txt.1
。另请参见
-x
选项,将它们放入目录树中。