2016-09-17 373 views
1

我試圖使用curl下載node解壓下載的焦油:現在CentOS的:不能使用curl

$> curl https://nodejs.org/dist/latest/node-v6.6.0.tar.xz | tar xz -C /opt 

,我的Mac上工作的。然而,在CentOS的,這不起作用:

$> curl https://nodejs.org/dist/latest/node-v6.6.0.tar.xz | tar xz -C /opt 
% Total % Received % Xferd Average Speed Time Time  Time Current 
          Dload Upload Total Spent Left Speed 
    0 14.8M 0 941 0  0 1214  0 3:33:54 --:--:-- 3:33:54 1214 
gzip: stdin: not in gzip format 
tar: Child died with signal 13 
tar: Error is not recoverable: exiting now 
0 14.8M 0 42083 0  0 51628  0 0:05:01 --:--:-- 0:05:01 51635 
curl: (23) Failed writing body (246 != 1369) 

我不明白究竟是怎麼回事之一。

如果我分裂的命令,做

$> curl https://nodejs.org/dist/latest/node-v6.6.0.tar.xz > node.tgz 
$> tar -xvf node.tgz // NOTE that I omitted the `z` 

它的工作原理。在此基礎上,也許已經卷曲解壓文件我試圖

$> curl https://nodejs.org/dist/latest/node-v6.6.0.tar.xz | tar x -C /opt 
% Total % Received % Xferd Average Speed Time Time  Time Current 
          Dload Upload Total Spent Left Speed 
0 14.8M 0 941 0  0 1005  0 4:18:23 --:--:-- 4:18:23 1004tar: Archive is compressed. Use -J option 
tar: Error is not recoverable: exiting now 
0 14.8M 0 17325 0  0 18258  0 0:14:13 --:--:-- 0:14:13 18256 
curl: (23) Failed writing body (428 != 1369) 

都能跟得上:(任何幫助將不勝感激?

回答

2

當您使用焦油應用程序的選項「-z」正在等待的.gz(gunzip解)格式

你應該使用選項「J」:?

curl https://nodejs.org/dist/latest/node-v6.6.0.tar.xz | tar xJ -C /tmp 
+0

日Thnx的解釋你知道爲什麼它在Mac –

+1

的Mac使用的libarchive的bsdtar,能自動偵測壓縮格式。 –