我想下載 git 儲存庫的 tar 並將其內容提取到另一個資料夾。
以下行(為清楚起見已分解)有效:
curl -L -0 nt-dotfiles.tar.gz https://api.github.com/repos/nicktomlin/laptop/tarball \
| tar --strip-components=1 -zx -C ~/Documents/dotfiles
但給了這個錯誤:
curl: (6) Could not resolve host: nt-dotfiles.tar.gz; nodename nor servname provided, or not known
我同意保持原樣(因為它仍然有效),但我對錯誤很好奇,如果它消失會感覺更好。
謝謝!
答案1
您的語法應該是:curl -L -o nt-dotfiles.tar.gz https://api. ...
您使用零而不是小寫“Oh”。零強制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"
答案2
您可以嘗試:
$ curl -s http://example.com/file.tgz | tar xvf - -C dest/