我正在尝试用一行命令下载和解压缩tar.xz文件。然而,它并不总是适用于所有的链接。我可以手动下载并解压它。
我可以下载glibc和提取没有任何问题。
curl https://ftp.gnu.org/gnu/glibc/glibc-2.26.tar.xz | tar -xJ -C ${PWD} --strip-components 1当它下载以下文件时,它令人惊讶地失败了。我找不出是什么造成了这种差异。这是我到目前为止所看到的唯一失败的环节。
知道为什么下面的命令失败了吗?
curl https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/arm-linux-gnueabihf/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz | tar -xJ -C ${PWD} --strip-components 1它在以下消息中失败。
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
xz: (stdin): File format not recognized
tar: Child returned status 1
tar: Error is not recoverable: exiting now 任何帮助都将不胜感激。
发布于 2019-12-12 23:16:32
使用curl -L跟踪重定向:
curl -L https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/arm-linux-gnueabihf/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz | tar -xJ --strip-components 1要调试这些问题,可以单独运行curl命令,并注意到在本例中,它不返回任何数据:
$ curl https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/arm-linux-gnueabihf/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz
$然后,您可以进一步运行curl -v来查看发生了什么。它显示了一个带有空体的HTTP/1.1 302 Found,并将其重定向到另一个文件,这就是如何添加-L以跟踪重定向。
https://stackoverflow.com/questions/59313987
复制相似问题