我想下载 git repo 的 tar 并将其内容解压缩到另一个文件夹。
以下行(为了清楚起见而分解)有效:
curl -L -0 nt-dotfiles.tar.gz https://api.github.com/repos/nicktomlin/laptop/tarball \
| tar --strip-components=1 -zx -C ~/Documents/dotfiles
Run Code Online (Sandbox Code Playgroud)
但给出了这个错误:
curl: (6) Could not resolve host: nt-dotfiles.tar.gz; nodename nor servname provided, or not known
我可以保持原样(因为它仍然有效),但我对错误很好奇,如果它消失了会感觉更好。
谢谢!
ken*_*orb 13
你可以试试:
$ curl -s http://example.com/file.tgz | tar xvf - -C dest/
Run Code Online (Sandbox Code Playgroud)
mca*_*lex 10
您的语法应该是:curl -L -o nt-dotfiles.tar.gz https://api. ... 您使用的是零而不是小写的“哦”。零强制 curl 使用 http1.0。'o' 提供输出文件名。
从手册页:
-0, --http1.0
(HTTP) Forces curl to issue its requests using HTTP 1.0 instead
of using its internally preferred: HTTP 1.1.
-o, --output <file>
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"
Run Code Online (Sandbox Code Playgroud)