不确定您的原始命令是否有效,因为 tar 的选项中有几个错误。
鉴于../MyFolder
存在,您的第一个命令需要是
pv large_file.tar.gz | tar -xz -C ../MyFolder
如果您在pv
和调用之间插入 tee 调用tar
,那么整个链条都会起作用。
pv large_file.tar.gz | tee /tmp/strout.log | tar -xz -C ../MyFolder
但是我不确定它是否符合您的期望。如果您将 pv 输出通过管道传输到 tee,则 tee 会将其通过管道传输到 tar,并将与原始 tar 相同的内容转储到 /tmp/strout.log,从而将您的 tar 提取../MyFolder
并复制到 /tmp/strout.log。
编辑
正如@DownloadPizza 所建议的,您可以使用进程替换(请参阅How do I write stderr to a file while using "tee" with a pipe?)。通过使用-f
pv 标志,您的命令将变为
pv -f large_file.tar.gz 2> >(tee /tmp/strout.log) > >(tar -xz -C ../MyFolder)
并将产生预期的输出。