Extract .tar.xz with pv progress bar

3.4k Views Asked by At

I have a problem with extracting files with a progress bar. It always gives me an error:

pv "file.tar.xz" | tar -xf

tar: need argument -- f
2

There are 2 best solutions below

3
On BEST ANSWER

The -f option requires the archive to operate on as an argument, see man tar(1).
Use - to extract from stdin (provided by the pipe pv "file.tar.xz" | in your case):

pv "file.tar.xz" | tar -xJf-

As - is usually the compiled-in default archive (you can probably check with tar --show-defaults), you might be able to omit the -f option altogether and simply use

pv "file.tar.xz" | tar -xJ
0
On

this work for me: pv "file.tar.gz" | tar -xzf - -C target_directory