I use

tar -cJvf resultfile.tar.xz files_to_compress

to create tar.xz and

tar -xzvf resultfile.tar.xz

to extract the archive in current directory. How to use multi threading in both cases? I don't want to install any utilities.

tar -c -I 'xz -9 -T0' -f archive.tar.xz [list of files and folders]
| improve this answer | |
  • Can you explain this answer with words? It’s not immediately clear to me what part enables multi threading. – SethMMorton Sep 7 at 18:56
  • 1
    man xz -> -T – Artem S. Tashkinov Sep 7 at 19:23
  • tar -c = create a tar, -I 'xz -9 -T0' = use the compress program xz -9 -T0 (ultra, use as many threads as CPU cores), -f = write the tar to archive.tar.xz – ZiggyTheHamster Oct 14 at 1:40
  • On my TAR though, -I won't accept arguments, and expects a program only. Maybe you can make a simple shell script that is exec xz -9 -T0 $*? – ZiggyTheHamster Oct 14 at 1:51
  • This program is used for piping, so $* is redundant. Also, not sure why you want to use exec. – Artem S. Tashkinov Oct 14 at 9:39

For older tars, this works:

tar -cf -  list of files and folders| xz -9 -T0 >| archive.tar.T.xz
| improve this answer | |
New contributor
Will Fischer is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.