wget和pipe道在后台焦油

我正在尝试下载大小为.tar.gz(> 2GB)的大文件。 bash脚本也做很多其他的事情,所以我想开始下载,然后继续处理bash脚本中的其他命令。 我正在使用wget和pipe道来tar并在后台运行它。

 wget -q "https://download-of-large-file-here.tar.gz" | tar xz & # other commands here 

但是,这是打破:

 gzip: stdin: unexpected end of file tar: Child returned status 1 tar: Error is not recoverable: exiting now 

任何想法如何使这项工作?

您必须指示wget写入STDOUT,您需要将-O -传递给wget,否则会将文件保存到磁盘。 tar失败,因为执行它期待从STDIN的东西。

这应该工作:

 wget -q -O - "https://download-of-large-file-here.tar.gz" | tar xz & 

其中-q取消STDOUT和-O -的默认进度信息-O -将输出文件设置为STDOUT。