I'm trying to extract large .tar file using pv.
pv large_file.tar.gz | tar -xcf /../MyFolder.
The pv command works like expected,showing the progress in the console.
I'm trying to split the stdout, to show the progress both in the console and save the same standout, to a file.
I tried doing so with tee, but couldn't make it work.
pv large_file.tar.gz | tee /tmp/strout.log | tar -xcf /../MyFolder
Any suggestions how can i display the progress to the console an in the same time save it to a file?
Thanks!
Not sure that your original command works, as there are several errors in the options given to tar.
Given that
../MyFolderexists, your first command need to beIf you insert tee call between
pvandtarcalls, then the whole chain works.However i'm not sure it does what you expect. If you pipe pv output to tee, tee will pipe it to tar, and dump the same contents as the original tar to /tmp/strout.log, resulting in your tar extracted to
../MyFolderand copied to /tmp/strout.log.EDIT
As suggested by @DownloadPizza, you can use process substitution (see How do I write stderr to a file while using "tee" with a pipe?). By using
-fflag with pv, your command will becomeand will produce expected output.